docker基础命令

docker

Posted by lwj108 on June 14, 2019

1.docker images –docker镜像 2.docker run -p 127.0.0.1:1521:1521 registry.aliyuncs.com/helowin/oracle_11g –运行oracle

创建一个数据卷 docker volume create my-vol

查看所有数据卷 docker volume ls

删除一个数据卷 docker volume rm my-vol

启动容器 docker start 容器id

停止容器 docker stop 容器id

删除容器 docker rm 容器id

删除容器后才可删除镜像(被容器使用中的镜像是无法删除的) docker rmi 镜像id

从 Docker 镜像仓库获取镜像的命令是 docker pull。其命令格式为: docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]

kafka相关命令

docker start zookeeper sudo docker run -d –name kafka –publish 9092:9092 –link zookeeper –env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 –env KAFKA_ADVERTISED_HOST_NAME=127.0.0.1 –env KAFKA_ADVERTISED_PORT=9092 –volume /Users/liweijun/Downloads:/etc/localtime wurstmeister/kafka

#进入kafka目录 docker exec -ti kafka /bin/bash cd /opt/kafka_2.12-2.2.0/bin #启动kafka sh kafka-server-start.sh ../config/server.properties

config/server.properties可以配置监听(多个端口需配置多个配置文件在kafka启动时选定对应的配置文件即可) 如 server1.properties advertised.listeners=PLAINTEXT://192.168.1.xxx:9092 port=9092 server2.properties advertised.listeners=PLAINTEXT://192.168.1.xxx:9093 port=9093

启动zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties &

启动kafka bin/kafka-server-start.sh config/server.properties &

停止kafka bin/kafka-server-stop.sh

停止zookeeper bin/zookeeper-server-stop.sh

创建topic bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test

展示topic bin/kafka-topics.sh –list –zookeeper localhost:2181

描述topic bin/kafka-topics.sh –describe –zookeeper localhost:2181 –topic my-replicated-topic

生产者: bin/kafka-console-producer.sh –broker-list localhost:9092 –topic my-replicated-topic

消费者: bin/kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginnin 如果创建消费者报错 consumer zookeeper is not a recognized option请使用下面命令 bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –from-beginning

查看topic bin/kafka-topics.sh –list –zookeeper localhost:2181