docker-compose inside Alpine container

情到浓时终转凉″ 提交于 2019-12-24 01:29:11

问题


I'm attempting to bundle my app (code, Dockerfiles and a docker-compose script) together inside a single image for easy deployment (entrypoint will just docker-compose up). My Dockerfile for this top level app image looks like so

FROM alpine:latest
COPY . /app
RUN apk update && apk add --no-cache docker py-pip openrc && pip install docker-compose

When I run this image, it seems that dockerd hasn't started, being absent from top results; docker ps reports "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ". If however I do service docker start, this returns " * WARNING: docker is already starting". Is there anything special I need to do to get Docker working side of an Alpine container?


回答1:


Docker consists of docker daemon, who runs all services, and CLI, used to interact with daemon (ok, there are lots of other parts, but these are most important). Installing docker-compose does not install daemon, regardless of what message you are getting from service command.

To use docker inside container, you have to use docker-in-docker image. It is called docker:dind. Inherit from it (instead of alpine) and enjoy.

But before read this article, which explains why it is not a great idea and what are other ways to use docker inside container (tip: you can call host's docker daemon from inside container with just mounting /var/run/docker.sock:/var/run/docker.sock socket).



来源:https://stackoverflow.com/questions/54711502/docker-compose-inside-alpine-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!