Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker自动化构建镜像和常用命令 #10

Open
yinxin630 opened this issue May 24, 2019 · 0 comments
Open

Docker自动化构建镜像和常用命令 #10

yinxin630 opened this issue May 24, 2019 · 0 comments
Labels

Comments

@yinxin630
Copy link
Owner

yinxin630 commented May 24, 2019

自动化构建镜像

  1. 在项目根目录添加 Dockerfile
  2. 前往 Docker Hub, 进入镜像详情页, 修改 Builds 配置开启自动构建

image

使用 docker-compose

docker-compose 是一个 docker 实用工具, 可以根据预先的配置, 一键启动一系列容器, 并处理好关联关系

这个是 fiora 的 docker-compose 配置: https://github.com/yinxin630/fiora/blob/master/docker-compose.yaml

常用命令:

  • docker-compose build: 构建镜像
  • docker-compose up: 运行镜像, --build参数: 构建并运行

docker常用命令

  • docker images: 列出本地镜像
  • docker container ls: 列出本地运行中的容器, -a参数: 列出所有容器
  • docker rm [id]: 删除容器
  • docker rmi [id]: 删除镜像
  • docker run [name]: 运行容器, --name:命名 --link:连接其他容器 -p:端口映射 --env:设置环境变量 --net=host:使用宿主机网络
  • docker system df: 查看磁盘空间占用
  • docker system prune: 清理空间, 删除不使用的数据

遇到的问题

应用容器连不上mongoDB容器

最后发现是基础镜像的原因, 如果用 node:10 或者 node:10-alpine 作为基础镜像, 就连不上. 用 node:alpine 做为基础镜像, 就可以

原因我也没搞清楚

@yinxin630 yinxin630 changed the title Docker相关 Docker自动化构建镜像和常用命令 May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant