2016-01-29 69 views
2

我有一個用於nginx的dockerfile。docker-compose圖像導出和導入

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 

運行後

碼頭工人,組成了

它創建從dockerfile圖像被稱爲 「網絡」 和下載Redis的形象也。它還創建兩個圖像被稱爲「web_web1」的組合,當我檢查

泊塢窗PS

兩個nginx的和Redis的服務的輸出運行。我的問題是,如果我將新創建的映像提交到另一個映像,並在執行docker run命令期間將容器導出到另一個環境,它是否會啓動nginx和redis服務?

回答

2

我的問題是,如果我將新創建的映像提交到另一個映像,並導出容器並導入另一個環境,在執行docker run命令期間,它是否會啓動nginx和redis服務?

所有你需要的是改變在docker-compose.yml聲明的容器名稱和端口映射,只要你想,如果有不同的IM,你可以啓動這些圖像的多個實例(無需導出/導入)

+0

用於節點,mongo和nginx的dockerfiles。現在我們可以自定義docker-compose.yml文件來運行所有的容器。 – user2439278

+0

@ user2439278你在問題中顯示的碼頭組成你就是這麼做的。我說的是,具有不同容器名稱和端口映射的* second * docker-compose.yml會再次啓動* nginx和redis。 – VonC