docker search java
- docker pull java:8
- docker pull macro/eureka-server:0.0.1
docker images
- docker rmi java
- docker rmi -f java
- docker rmi -f $(docker images)
docker run -d -p 91:80 nginx
docker ps
docker stop $ContainerId
docker kill $ContainerId
docker start $ContainerId
- docker inspect --format "{{.State.Pid}}" $ContainerId
- nsenter --target "$pid" --mount --uts --ipc --net --pid
- docker rm $ContainerId
- docker rm -f $(docker ps -a -q)
docker run -d -p 5000:5000 --restart=always --name registry2 registry:2
docker push localhost:5000/macro/eureka-server:0.0.1
docker tag macro/eureka-server:0.0.1 localhost:5000/macro/eureka-server:0.0.1
- command:mvn clean package docker:build
- tip: Linux服务器需要开启远程api:vi /usr/lib/systemd/system/docker.service 修改为:ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
- command:mvn clean package docker:build -DpushImage
- tip: pom.xml修改192.168.1.71:5000/macro/${project.artifactId}:${project.version}
- tip: docker要支持http:echo '{ "insecure-registries":["192.168.1.71:5000"] }' > /etc/docker/daemon.json
- 查看Docker的存放位置:docker info | grep "Docker Root Dir"(默认为/var/lib/docker)
- 关闭Docker服务:systemctl stop docker
- 移动目录到目标路径:mv /var/lib/docker /root/data/docker
- 建立软连接:ln -s /root/data/docker /var/lib/docker
- 下载地址:https://github.com/docker/compose/releases
- 安装地址:/usr/local/bin/docker-compose
- 设置为可执行:sudo chmod +x /usr/local/bin/docker-compose
- 测试是否安装成功:docker-compose --version
sudo curl -L https://raw.githubusercontent.com/docker/compose/1.22.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
- 构建、创建、启动相关容器:docker-compose up
- 列出所有容器:docker-compose ps
- 删除指定服务的容器:docker-compose rm eureka
- 对容器进行动态扩容:docker-compose scale eureka=3
- 停止相关容器:docker-compose stop eureka
- 启动相关容器:docker-compose start eureka
- eureka-server
- hello-service
- feign-consumer
- api-gateway
- 编排SpringCloud微服务:见eureka-server/docker-res/docker-compose.yml
- 简化SpringCloud微服务编排:见eureka-server/docker-res/docker-compose-simple.yml
- 编排高可用的注册中心:见eureka-server/docker-res/docker-compose-eureka.yml