简体   繁体   中英

docker-compose image export and import

I have a dockerfile for nginx.

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.

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. It also creates combination of both image called "web_web1" and when i checked the output of

docker ps

both nginx and redis service are running. 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?

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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