[英]How to convert a Dockerfile to a docker compose image?
This is how I'm creating a docker image with nodeJS and meteorJS based on an ubuntu image. 这就是我如何使用nodeJS和基于ubuntu图像的meteorJS创建docker镜像。 I'll use this image to do some testing.
我将使用此图像进行一些测试。
Now I'm thinking of doing this via docker compose. 现在我想通过docker compose这样做。 But is this possible at all?
但这有可能吗? Can I convert those commands into a docker compose yml file?
我可以将这些命令转换为docker compose 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 doesn't replace your Dockerfile, but you can use Docker Compose to build an image from your Dockerfile : Docker Compose不会替换您的Dockerfile,但您可以使用Docker Compose 从Dockerfile构建映像 :
version: '3'
services:
myservice:
build:
context: /path/to/Dockerfile/dir
dockerfile: Dockerfile
image: result/latest
Now you can build it with: 现在你可以用它构建它:
docker-compose build
And start it with: 从以下开始:
docker-compose up -d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.