如何将一个Dockerfile转换成一个Docker组合图像?

这就是我如何使用基于ubuntu镜像的nodeJS和meteorJS创builddocker镜像。 我将使用这个图像做一些testing。

现在我正在考虑通过docker撰写。 但是这是可能的吗? 我可以将这些命令转换成一个泊坞窗撰写yml文件吗?

FROM ubuntu:16.04 COPY package.json ./ RUN apt-get update -y && \ apt-get install -yqq \ python \ build-essential \ apt-transport-https \ ca-certificates \ curl \ locales \ nodejs \ npm \ nodejs-legacy \ sudo \ git ## NodeJS and MeteorJS RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - RUN curl https://install.meteor.com/ | sh ## Dependencies RUN npm install -g eslint eslint-plugin-react RUN npm install ## Locale ENV OS_LOCALE="en_US.UTF-8" RUN locale-gen ${OS_LOCALE} ENV LANG=${OS_LOCALE} LANGUAGE=en_US:en LC_ALL=${OS_LOCALE} ## User RUN useradd ubuntu && \ usermod -aG sudo ubuntu && \ mkdir -p /builds/core/.meteor /home/ubuntu && \ chown -Rh ubuntu:ubuntu /builds/core/.meteor && \ chown -Rh ubuntu:ubuntu /home/ubuntu USER ubuntu 

Docker Compose不会replace您的Dockerfile,但您可以使用Docker Compose 从Dockerfile构build一个图像 :

 version: '3' services: myservice: build: context: /path/to/Dockerfile/dir dockerfile: Dockerfile image: result/latest 

现在你可以用它来构build它:

 docker-compose build 

并开始:

 docker-compose up -d