Reputation: 1397
I have the following content in docker compose to spin up my docker:dind service
dind:
image: docker:dind
container_name: dind
privileged: true
command: ['dockerd', '--iptables=false', '--config-file=/etc/docker/daemon.json']
networks:
isolated_network:
ipv4_address: 172.16.0.4
restart: always
hostname: 'Dindy'
volumes:
- ./volumes/dind/config:/etc/docker
- ./volumes/dind/var/lib/docker:/var/lib/docker
and that works for me, but it is not perfect. I have to configure the service by creating volume/dind/config/daemon.json
first. This does not feel like the intended way.
So I tried to build with a docker file and copy the daemon in there.
FROM docker:dind
RUN mkdir /etc/docker
COPY ./daemon.json /etc/docker
That works after removing the mapping ./volumes/dind/config:/etc/docker
in the docker-compose.json
file, otherwise docker logs dind
would say:
unable to configure the Docker daemon with file /etc/docker/daemon.json: open /etc/docker/daemon.json: no such file or directory
The missing volume mapping is ok, I do not need it any more. I am still puzzled why I need to remove it.
Anyhow, I have to create a new image via Dockerfile
just to copy my daemon.json
file. Or otherwise I have to populate the volumes directory with the daemon.json
file.
Other suggestions how to solve this?
UPDATE maybe this solution is the best? Just found it after posting.
Upvotes: 0
Views: 149
Reputation: 1397
I found a configs command in docker compose which does what I need. See documentation here
So my docker-compose.yml, the dind
service, looks like this now, note the new configs:
section:
dind:
image: docker:dind
container_name: dind
privileged: true
command: ['dockerd', '--iptables=false', '--config-file=/etc/docker/daemon.json']
networks:
isolated_gitlab:
ipv4_address: 172.16.0.4
restart: always
hostname: 'gitlab-dind'
configs:
- source: dind_daemon_json
target: /etc/docker/daemon.json
volumes:
- ./volumes/dind/var/lib/docker:/var/lib/docker
. . .
configs:
dind_daemon_json:
file: ./context/dind/daemon.json
Upvotes: 0