【问题标题】:docker-compose image export and importdocker-compose 图像导出和导入
【发布时间】:2016-01-29 07:21:38
【问题描述】:

我有一个用于 nginx 的 dockerfile。

FROM ubuntu

# File Author / Maintainer
MAINTAINER Maintaner Name

# Install Nginx

# Add application repository URL to the default sources
RUN echo "deb http://archive.ubuntu.com/ubuntu/ raring main universe" >> /etc/apt/sources.list

# Update the repository
RUN apt-get update

# Install necessary tools
RUN apt-get install -y nano wget dialog net-tools

# Download and Install Nginx
RUN apt-get install -y nginx  

# Remove the default Nginx configuration file
RUN rm -v /etc/nginx/nginx.conf

# Copy a configuration file from the current directory
ADD nginx.conf /etc/nginx/

# Append "daemon off;" to the beginning of the configuration
RUN echo "daemon off;" >> /etc/nginx/nginx.conf

# Expose ports
EXPOSE 80

# Set the default command to execute
# when creating a new container
CMD service nginx start

我有一个 docker-compose.yml 文件。

web:
  build: .
  ports:
   - "5000:5000"
  volumes:
   - .:/code
  links:
   - redis
redis:
  image: redis

运行后

码头工人组成

它从名为“web”的 dockerfile 创建图像并下载 redis 图像。它还创建了名为“web_web1”的图像的组合,当我检查了

的输出时

码头工人ps

nginx 和 redis 服务都在运行。我的问题是,如果我将新创建的镜像提交到另一个镜像并导出容器并导入另一个环境,在执行 docker run 命令期间,它会同时启动 nginx 和 redis 服务吗?

【问题讨论】:

    标签: docker dockerfile docker-compose


    【解决方案1】:

    我的问题是,如果我将新创建的镜像提交到另一个镜像并导出容器并导入另一个环境,在执行 docker run 命令期间,它会同时启动 nginx 和 redis 服务吗?

    您只需要更改docker-compose.yml 中声明的容器名称和端口映射,您就可以启动任意数量的这些图像实例(无需导出/导入)

    【讨论】:

    • 如果我对节点、mongo 和 nginx 有不同的 dockerfile。现在我们可以自定义 docker-compose.yml 文件来运行所有容器了
    • @user2439278 您在问题中显示的 docker-compose 就是这样做的。我要说的是具有不同容器名称和端口映射的 second docker-compose.yml 将启动 again nginx 和 redis。
    猜你喜欢
    • 1970-01-01
    • 2017-06-27
    • 2016-08-05
    • 2016-10-16
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多