常用指令
#容器
docker ps -a
docker restart id
docker stop id
docker rm -f [id]
#镜像
docker rmi -f [id]
安装/启动
curl -fsSL https://get.docker.com | bash -s docker --mirror aliyun
sudo systemctl start docker
jdk
- pull
docker pull openjdk:11
- run
docker run -d -it --name java-11 openjdk:11
- check
docker exec -it 297e246f6078 /bin/bash
java -version
mysql
- pull
docker pull mysql:latest
- run
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
- mysql8 客户端连接出错
Public Key Retrieval is not allowed
allowPublicKeyRetrieval=true
私有仓库
- pull
docker pull registry:2
- run
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --name myregistry registry:2
jar(1)
- 上传jar
- 同级目录创建Dokcerfile
FROM openjdk:11
EXPOSE 8091
ADD base-1.0.jar /base.jar
ENTRYPOINT ["java", "-jar","/base.jar"]
- build
docker build -t baseapp .
- run
docker run -d -p 8091:8091 baseapp
- tail log
docker logs -f --tail 500 id