实例:
[root@liuxin ~]# docker pull mysql:latest
latest: Pulling from library/mysql
8559a31e96f4: Already exists
d51ce1c2e575: Pull complete
c2344adc4858: Pull complete
fcf3ceff18fc: Pull complete
16da0c38dc5b: Pull complete
b905d1797e97: Pull complete
4b50d1c6b05c: Pull complete
571e8a282156: Pull complete
e7cc823c6090: Pull complete
61161ba7d2fc: Pull complete
74f29f825aaf: Pull complete
d29992fd199f: Pull complete
Digest: sha256:fe0a5b418ecf9b450d0e59062312b488d4d4ea98fc81427e3704f85154ee859c
Status: Downloaded newer image for mysql:latest
[root@liuxin ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 6e447ce4863d 47 hours ago 544MB
nginx latest 0901fa9da894 5 days ago 132MB
tomcat latest 6055d4d564e1 9 days ago 647MB
tomcat 9-jre8 e24825d32965 14 months ago 464MB
命令:
[root@liuxin ~]# docker run -it --rm \
> ubuntu:latest \
> bash
实例
[root@liuxin ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 6e447ce4863d 47 hours ago 544MB
nginx latest 0901fa9da894 5 days ago 132MB
ubuntu latest adafef2e596e 9 days ago 73.9MB
tomcat latest 6055d4d564e1 9 days ago 647MB
redis latest 235592615444 5 weeks ago 104MB
tomcat 9-jre8 e24825d32965 14 months ago 464MB
[root@liuxin ~]# docker run -it --rm \
> ubuntu:latest \
> bash
root@cbe63b114858:/# ls
bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
命令:docker images
[root@liuxin ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 6e447ce4863d 47 hours ago 544MB
nginx latest 0901fa9da894 5 days ago 132MB
tomcat latest 6055d4d564e1 9 days ago 647MB
tomcat 9-jre8 e24825d32965 14 months ago 464MB
1)方式一:docker image rm j镜像名:版本号
2)方式二:docker rmi 镜像ID
docker rmi $(docker images -q)
命令格式:
docker run -p 运行端口号:8080 tomcat:版本号
例:
[root@liuxin ~]# docker run -p 8085:8080:7.0.57
docker container prune
docker run -p 8085:8080 --name 容器名称(自定义) -d tomcat:7.0.57
1)docker stop 容器ID
2)docker container stop 容器ID
3)docker container stop 容器的名字
4)停止所有正在运行的容器:docker stop $(docker ps -a -q)
docker run -p 8080:8080 --name tomcat12 -d -v /usr/local/docker/tomcat/ROOT:/usr/local/tomcat/webapps/ROOT tomcat:7.0.57
docker exec -it 容器的名字 bash
例:
docker exec -it tomcat12 bash