Docker命令行

鏡像命令:
docker image ls
docker images --digests
docker images javahtml

docker pull [選項] [DockerRegistry地址:端口號]/倉庫名:[標籤]
docker buildjava

容器命令:
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 linux

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/nginx

構建項目:
wprovider-0.0.1-SNAPSHOT.jar
touch Dockerfile
vim Dockerfile
FROM java:8
VOLUME /tmp
ADD wprovider-0.0.1-SNAPSHOT.jar app.jar
RUN bash -c 'touch /app.jar'
EXPOSE 8761
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
docker build -t wprovider:0.0.1 .
docker run -d -p 8761:8761 wprovider:0.0.1
docker ps -s
docker attach 642cfee09cfb
docker inspect --format "{{State.Pid}}" 642cfee09cfb
nsenter --target 95492 --mount --uts --ipc --net --piddocker

docker push wprovider:0.0.1json

 


其餘:
docker rmi [鏡像]
docker image rm [選項] <鏡像1> [<鏡像2> ...]
docker rmi -f $(docker images)vim

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.tarcentos

 

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-worldbash

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 dockerapp

2,卸載docker-ce
sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

3,創建docker用戶組:sudo group add dockersudo user mod -aGdockerdocker

相關文章
相關標籤/搜索