Docker教程

docker 命令列表

  • docker build
  • docker run
  • docker network
  • docker exec
  • docker inspect
  • docker tag
  • docker login
  • docker ps
  • docker stop
  • docker images
  • docker rmi
  • docker search
  • docker pull
  • docker push

Dockerfile关键词列表

  • FROM
  • VOLUME
  • ARG
  • ENV
  • ADD
  • COPY
  • EXPOSE
  • WORKDIR
  • ENTRYPOINT
  • USER
  • CMD
  • RUN

docker build命令执行示例

1
docker build -t hexo_docker:1.0.1 --no-cache .

docker run命令执行示例

1
docker run hexo_docker:1.0.1

docker 命令执行示例

1
docker exec -it ${容器ID} /bin/bash 

docker ps

1
2
docker ps
docker ps -a

docker rm ${容器ID}

  • 删除容器

docker rmi ${镜像ID}

  • 删除镜像

docker tag

  • docker tag : 标记本地镜像,将其归入某一仓库
  • docker tag demo:0.0.1-SNAPSHOT yitianyigexiangfa/springboot-k8s-tutorial:1.0
1
2
3
docker search nginx
docker search -f stars=10 java
docker search yitianyigexiangfa

docker pull

1
docker pull yitianyigexiangfa/k8s_tutorial_fortune:1.0

docker push

1
docker push yitianyigexiangfa/k8s_tutorial_fortune:1.0

docker hub

  • 类似于github里有存了很多开源代码,docker hub里存了很多开放的容器
  • 例如redis在docker hub的地址是这样的

Dockerfile例子

1
2
3
FROM java:8
COPY target/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]