node.js - 如何将 Dockerfile 转换为 docker compose 镜像?

标签 node.js meteor docker docker-compose

这就是我基于 ubuntu 图像使用 nodeJS 和 meteorJS 创建 docker 图像的方式。我将使用此图像进行一些测试。

现在我正在考虑通过 docker compose 来做这件事。但这可能吗?我可以将这些命令转换为 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 不会替换您的 Dockerfile,但您可以使用 Docker Compose 来 build an image from your Dockerfile :

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

现在您可以使用:

docker-compose build

然后开始:

docker-compose up -d

关于node.js - 如何将 Dockerfile 转换为 docker compose 镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44036337/

相关文章:

javascript - 使用变量作为 find() 内投影的字段说明符

javascript - 为笔记本电脑和移动设备使用不同的元素?

node.js - 使用 Bazel 构建 Node.Js Docker 镜像

javascript - 修复 : Use global instead of window

node.js - 如何在实时添加对象时从 Redis 中弹出对象?

javascript - Meteor NodeJs base64 转换回文件

python - 如何使用 docker-py 中的副本将文件从容器复制到主机

mysql - 对两列值组合的唯一约束

node.js - 如何创建变量 Mustache 变量?

docker - 在 Docker 中添加或复制文件夹