docker – 组成图像导出和导入

我有一个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 

跑完之后

docker工人组成

它会从名为“web”的dockerfile创build映像,并且还会下载redis映像。 它还创build了名为“web_web1”的图像和当我检查输出的组合

docker工人

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

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

您只需更改docker-compose.yml声明的容器名称和端口映射,即可启动尽可能多的这些映像实例(无需导出/导入)