Docker in Docker networking problems: unable to expose ports

#1

Hi,
I am trying to run docker in docker but I cant seem to reach the services starting in the dind over the network.
dockerd seems to come up and running correctly but the the container published ports are not reachable.

Am i missing a step? Do i need to join a specific docker network or link the container somehow?

See pipeline below:

kind: pipeline
name: default

services:
- name: docker
  image: docker:dind
  pull: always
  privileged: true
  volumes:
  - name: dockersock
    path: /var/run/

volumes:
- name: dockersock
  temp: {}

steps:

- name: test
  image: docker
  pull: always
  volumes:
  - name: dockersock
    path: /var/run
  commands:
  - docker ps
  - docker run -d -p 8080:80 httpd:alpine
  - wget docker:8080
  - echo index.html

My drone config:

version: '3.4'

services:

  drone:
    image: drone/drone:1
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    ports:
      - "8080:80"
      - "443:443"
    environment:
      DRONE_GITEA_SERVER: "https://giteahost"
      DRONE_GIT_ALWAYS_AUTH: "true"
      DRONE_RUNNER_CAPACITY: "2"
      DRONE_SERVER_HOST: "thehostname:8080"
      DRONE_SERVER_PROTO: "http"
      DRONE_TLS_AUTOCERT: "false"
      DRONE_USER_FILTER: "dev"
      DRONE_LOGS_DEBUG: "false"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/var/lib/drone:/data"

Build step output:

+ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
+
+ docker run -d -p 8080:80 httpd:alpine
Unable to find image 'httpd:alpine' locally
alpine: Pulling from library/httpd
bdf0201b3a05: Pulling fs layer
7050d01d3056: Pulling fs layer
0d24d6c93d86: Pulling fs layer
8dd5947c3bef: Pulling fs layer
cfeedfe004a2: Pulling fs layer
8dd5947c3bef: Waiting
cfeedfe004a2: Waiting
0d24d6c93d86: Verifying Checksum
0d24d6c93d86: Download complete
7050d01d3056: Verifying Checksum
7050d01d3056: Download complete
bdf0201b3a05: Verifying Checksum
bdf0201b3a05: Download complete
bdf0201b3a05: Pull complete
7050d01d3056: Pull complete
0d24d6c93d86: Pull complete
cfeedfe004a2: Verifying Checksum
cfeedfe004a2: Download complete
8dd5947c3bef: Verifying Checksum
8dd5947c3bef: Download complete
8dd5947c3bef: Pull complete
cfeedfe004a2: Pull complete
Digest: sha256:e0883303f41497653ace285791081a68181a340d6736b4ff11dfa7ae13d82ecd
Status: Downloaded newer image for httpd:alpine
1cb4f78787c49595f469e3abefad99060a1800c39d80f36d844f6a1e5bf8f95c
+ wget docker:8080
Connecting to docker:8080 (172.31.89.2:8080)
wget: can't connect to remote host (172.31.89.2): Connection refused
How to start Kubernetes in a pipeline for e2e tests?
#2

Does anybody use Docker in Docker in Drone pipelines?
Is this supposed to work or have i misconfigured something?

Thanks.

#3

see the following verified working example https://docs.drone.io/examples/service/docker_dind/

#4

Unfortunately that example does not show working network access between the pipeline and the docker containers.

But that example is what i followed during set up - could not get it to work.

Would appreciate if someone can confirm docker dind works with networking.

Thanks.