I am trying to run TeamCity CI Server within Docker DinD(Docker in Docker) by using a dockerfile. I am using the official docker:19-dind
image as the base image.
The main purpose is to create a DinD container and run TeamCity's official container within that DinD container. First of all, is that really possible using DinD?
The dockerfile is as follows:
.dockerignore
# Official Docker in Docker 19 version as base image.
FROM docker:19-dind AS base
# Create work directory
WORKDIR /teamcity-ci-server
# Command to check version
RUN docker --version
# Final image inherited from base image
FROM base as final
# Adding directory
WORKDIR /teamcity-ci-server
# Run commands to setup TeamCity CI Server
RUN docker pull jetbrains/teamcity-server \
&& docker images \
&& docker run -d --privileged --name teamcity-ci-server -p 5002:8111 jetbrains/teamcity-server
# Add volume mount for DinD
VOLUME /var/run/docker.sock:/var/run/docker.sock
# Exposing port
EXPOSE 5001
However, after running docker build -f .dockerignore -t teamcity-ci-server:v1 .
, I am getting the following error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I believe that this error is displaying because docker is not running. Think I cannot run systemctl start docker
since this is not a linux image and systemctl does not work here.
Does anyone know how to fix this issue that's happening within Docker DinD images?