Docker命令
1、镜像
docker version
docker info
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 4 months ago 13.3kB
docker images -a
-q
docker search mysql
Options:
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print search using a Go template
--limit int Max number of search results (default 25)
--no-trunc Don't truncate output
[root@lutrra /]
--filter-STARS=5000
docker pull mysql [:tag]
docker pull mysql:5.7
docker rmi -f [ID]
docker rmi -f [name]
doccker rmi -f $(docker imaeges -aq)
2.容器命令
Docker Hub Container Image Library | App Containerization
docker pull centos
docker run [参数] image
--name="名字"
-d
-it
-p
-P
docker run -it centos /bin/bash
exit
docker ps
docker ps -a
docker ps -aq
docker rm 容器ID
docker rm -f $(docker ps -aq)
docker start 容器ID
docker restart 容器id
docker stop 容器ID
docker kill 容器id
3、其他常用
docker run -d centos
docker logs -tf --tail
-tf
--tail
docker top id
docker inspect id
docker exec -it id /bin/bash
docker attach id
docker cp 容器id:文件路径 目的主机位置
4.练习
安装nginx
docker search nginx
docker pull nginx
docker run -d --name nginx-01 -p 80:80 nginx
curl localhost:80
whereis nginx
安装tomcat
docker run -it --rm tomcat:9.0
docker pull tomcat:9.0
docker run -d --name tomcat-01 tomcat
docker exec -it tomcat-01 /bin/bash
cd /usr/local/tomcat
cp -r webapps.dist/* webapps
部署es+kibina
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
curl localhost:9200
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS=
"-Xms64m -Xmx512m" elasticsearch:7.6.2
|