简体   繁体   English

如何将Dockerfile转换为docker compose图像?

[英]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.

相关问题 如何在没有 Dockerfile 的情况下设置 Docker 组合? - How to setup Docker Compose without a Dockerfile? 如何使用 docker-compose 文件中的命名图像和指定图像的 Dockerfile 启动命名 NodeJS 容器? - How to start a named NodeJS container with a named image from a docker-compose file and and a Dockerfile specifying the image? 如何从 Dockerfile 或 docker-compose 运行 knex 迁移 - How to run knex migrations from Dockerfile or docker-compose 使用 SSH 代理与 Docker 组合和 Dockerfile - Using SSH agent with Docker Compose and Dockerfile 如何使用包含数据库创建的 dockerfile 构建 docker 镜像 - How to build an docker image using dockerfile which includes databases creation 如何改进我的 Dockerfile 以完美地为 Angular 应用程序创建 Docker 图像? - How to improve my Dockerfile to create an Docker image for Angular application perfectly? 无法调试节点,使用 nodemon,dockerfile 和 docker-compose - Can't debug node, with nodemon, dockerfile and docker-compose 使Dockerfile VOLUME的行为类似于docker-compose卷 - Make Dockerfile VOLUME behave like docker-compose volumes 如何在不使用 Dockerfile 的情况下仅使用 Docker-compose.yml 文件启动 Node.js 应用程序的容器 - How to start the container for the Node.js application using just Docker-compose.yml file without using the Dockerfile 如何在使用docker-compose时为mongodb图像添加--auth? - how to add --auth for mongodb image when using docker-compose?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM