0

To create a docker image for a tileserver i want to include the generation of the tilemaps via https://github.com/openmaptiles/openmaptiles/blob/master/QUICKSTART.md into the build process.

For that i would need to "RUN docker-compose" during the image build process.

FROM debian:jessie

RUN apt-get update \
    && apt-get -y install apt-utils

RUN apt-get update \
    && apt-get -y install   ca-certificates curl

ENV DOCKER_VERSION 1.12.3
ENV COMPOSE_VERSION 1.9.0

RUN curl -L https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz > /tmp/docker-${DOCKER_VERSION}.tgz \
 && tar -zxf /tmp/docker-${DOCKER_VERSION}.tgz -C /tmp \
 && cp /tmp/docker/docker /usr/local/bin/docker \
 && chmod +x /usr/local/bin/docker \
 && rm -rf /tmp/docker-${DOCKER_VERSION}.tgz /tmp/docker \
 && curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-Linux-x86_64 > /usr/local/bin/docker-compose \
 && chmod +x /usr/local/bin/docker-compose

# check installation
RUN docker-compose -v

# install git
RUN apt-get -y install git-core

# install gawk
RUN apt-get -y install gawk

# install make
RUN apt-get -y install make

# Clone Maptiles Repo
RUN git clone https://github.com/digitalegarage/openmaptiles /openmaptiles

RUN cd /openmaptiles \
    && bash quickstart.sh bayern

# Start Maptiels Server
# on port 8080
CMD make start-tileserver

Trying to build this dockerfile seems to succefully install docker-compose but starting docker-compose via the bash script results in the following error

Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

2 Answers 2

1

🎉Docker Build Kit


You have to mount volume /var/run/docker.sock:/var/run/docker.sock:ro to intermediate containers while building images.

For sure, you know how to mount volumes with typical containers. However, the case here is intermediate containers.

Can we do it ?

Brief answer:

Yes using the experimental feature "build kit".

Detailed answer:

step1: Dockerfile

  • At the beginning of the Dockerfile put this line :

    # syntax=docker/dockerfile:experimental
    
  • Mount volumes inside Dockerfile as following:

    RUN --mount=type=bind,target=/var/run/docker.sock,source=/var/run/docker.sock \
        docker-compose -v
    

    In general, Use this mount with any "RUN" that requires communication with the docker engine.

step2: Build the image:

  • export this variable before running docker build :

    export DOCKER_BUILDKIT=1
    

Now build your new image like a Boss :

    docker build ...
Sign up to request clarification or add additional context in comments.

Comments

0

You are getting this error because docker daemon is not running inside your container. So you need to have a connection with any host that running docker daemon and specified DOCKER_HOST env variable. I suggest you link your container with another docker-in-docker container(https://hub.docker.com/_/docker/). Take a look into one of the existing docker-in-docker solutions out there.

2 Comments

first, thank you for that quick answer. I already used the default docker-in-docker image resulting in the same error. Because its easyer to use the bash script im using debain and install docker with RUN curl -L get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz > /tmp/docker-${DOCKER_VERSION}.tgz \ && tar -zxf /tmp/docker-${DOCKER_VERSION}.tgz -C /tmp \ && cp /tmp/docker/docker /usr/local/bin/docker \
i think that there could be a difference beetween starting docker-compose in dockerfile build and running container

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.