简体   繁体   English

docker-compose图像导出和导入

[英]docker-compose image export and import

I have a dockerfile for nginx. 我有一个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

and i have a docker-compose.yml file. 我有一个docker-compose.yml文件。

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

after running 跑完之后

docker-compose up 码头工人组成

it creates image from dockerfile called "web" and downloads redis image also. 它从名为“web”的dockerfile创建图像,并下载redis图像。 It also creates combination of both image called "web_web1" and when i checked the output of 它还创建了名为“web_web1”的图像和我检查输出时的组合

docker ps 码头工人

both nginx and redis service are running. nginx和redis服务都在运行。 My question is if i commit the newly created image to another image and export the container and import to another environment, during execution of docker run command,will it start both the nginx and redis service? 我的问题是,如果我将新创建的图像提交到另一个图像并导出容器并导入到另一个环境,在执行docker run命令期间,它是否会启动nginx和redis服务?

My question is if i commit the newly created image to another image and export the container and import to another environment, during execution of docker run command,will it start both the nginx and redis service? 我的问题是,如果我将新创建的图像提交到另一个图像并导出容器并导入到另一个环境,在执行docker run命令期间,它是否会启动nginx和redis服务?

All you need is change the container names and port mapping declared in the docker-compose.yml , and you could launch as many instances of those images as you want (no need to export/import) 您所需要的只是更改docker-compose.yml声明的容器名称和端口映射,您可以根据需要启动这些图像的多个实例(无需导出/导入)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM