Docker命令行
Posted wanhua-wu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker命令行相关的知识,希望对你有一定的参考价值。
镜像命令:
docker image ls
docker images --digests
docker images java
docker pull [选项] [DockerRegistry地址:端口号]/仓库名:[标签]
docker build
容器命令:
docker ps -s
docker run java:8 /bin/echo ‘hello world‘
docker run -d -p 91:80 nginx
docker stop 4d110d186a70
docker kill 1d48b7e52fac
docker start 1d48b7e52fac
docker restart 1d48b7e52fac
docker rm 1d48b7e52fac
docker rm -f $(docker ps -a -q)
docker export d9f19cb54132 > nginx.tar
docker export --output="nginx.tar" d9f19cb54132
docker import nginx.tar nginx
Dockerfile命令:
vim Dockerfile
FROM nginx
RUN echo ‘<h1> Spring Cloud与Docker微服务实战</h1>‘ > /usr/share/nginx/html/index.html
docker build -t nginx:my .
docker run -d -p 92:80 nginx:my
访问:http://192.168.74.128:92/
其他:
docker rmi [镜像]
docker image rm [选项] <镜像1> [<镜像2> ...]
docker rmi -f $(docker images)
docker save hello-world > hello-world.tar
docker save --output hello-world.tar hello-world
docker load < hello-world.tar
docker load --input hello-world.tar
1,docker-ce安装:
yum remove dockerdocker-common docker-selinuxdocker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager \
--add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum install docker-ce
yum list docker-ce --showduplicates | sort -r
sudo yum install <FULLY-QUALIFIED-PACKAGE-NAME> example:docker-ce-17.06.1.ce
sudo systemctl enable docker
sudo chkconfig docker on
sudo systemctl start docker
docker version
docker run hello-world
2,配置镜像加速器:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF‘
"registry-mirrors": ["https://urh00mp2.mirror.aliyuncs.com"]
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
2,卸载docker-ce
sudo yum remove docker-ce
sudo rm -rf /var/lib/docker
3,建立docker用户组:
sudo group add docker
sudo user mod -aGdockerdocker
以上是关于Docker命令行的主要内容,如果未能解决你的问题,请参考以下文章