Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using networks in Dockerfile.j2 make the build failing #24

Closed
ehartmann opened this issue Nov 8, 2022 · 1 comment · Fixed by #195
Closed

Using networks in Dockerfile.j2 make the build failing #24

ehartmann opened this issue Nov 8, 2022 · 1 comment · Fixed by #195
Labels

Comments

@ehartmann
Copy link

When attaching a network to an image to be built, the task Build an Ansible compatible image (new) is failing with this error message :

TASK [Build an Ansible compatible image (new)] *********************************
failed: [localhost] (item=molecule_local/ubuntu:focal) => {"ansible_loop_var": "item", "attempts": 3, "changed": false, "item": {"ansible_index_var": "i", "ansible_loop_var": "item", "changed": false, "checksum": "427fd5c760fa188bddada9aa5ea68e5bb0ee04bc", "dest": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal", "diff": {"after": {"path": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal"}, "before": {"path": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal"}}, "failed": false, "gid": 1000, "group": "eric", "i": 0, "invocation": {"module_args": {"_diff_peek": null, "_original_basename": "Dockerfile.j2", "access_time": null, "access_time_format": "%Y%m%d%H%M.%S", "attributes": null, "dest": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal", "follow": true, "force": false, "group": null, "mode": "0600", "modification_time": null, "modification_time_format": "%Y%m%d%H%M.%S", "owner": null, "path": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal", "recurse": false, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": null, "state": "file", "unsafe_writes": false}}, "item": {"cgroupns_mode": "host", "command": "", "docker_networks": [{"name": "teleport-network"}], "exposed_ports": ["443/tcp"], "groups": ["all", "proxy"], "image": "ubuntu:focal", "name": "ubuntu-focal-proxy", "network_mode": "teleport-network", "pre_build_image": false, "privileged": true, "tmpfs": ["/run", "/tmp"], "volumes": ["/sys/fs/cgroup:/sys/fs/cgroup:rw", "/var/lib/containerd"]}, "mode": "0600", "owner": "eric", "path": "/home/eric/.cache/molecule/ansible-role-teleport/default/Dockerfile_ubuntu_focal", "size": 1494, "state": "file", "uid": 1000}, "msg": "Error building molecule_local/ubuntu - code: None, message: network teleport-network not found, logs: ['Step 1/6 : FROM ubuntu:focal', '', 'Pulling from library/ubuntu', 'Digest: sha256:450e066588f42ebe1551f3b1a535034b6aa46cd936fe7f2c6b0d72997ec61dbd', 'Status: Image is up to date for ubuntu:focal', ' ---> 680e5dfb52c7', 'Step 2/6 : RUN apt-get update &&     apt-get install -y --no-install-recommends       python3       locales       ca-certificates       systemd       systemd-sysv       openssl       apt-transport-https       gpg-agent       gnupg       iproute2       sqlite3       iputils-ping inetutils-traceroute net-tools vim       python3-apt &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&     cd /lib/systemd/system/sysinit.target.wants/ &&     ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1 &&     rm -f /lib/systemd/system/multi-user.target.wants/* &&     rm -f /etc/systemd/system/*.wants/* &&     rm -f /lib/systemd/system/local-fs.target.wants/* &&     rm -f /lib/systemd/system/sockets.target.wants/*udev* &&     rm -f /lib/systemd/system/sockets.target.wants/*initctl* &&     rm -f /lib/systemd/system/basic.target.wants/* &&     rm -f /lib/systemd/system/anaconda.target.wants/* &&     rm -f /lib/systemd/system/plymouth* &&     rm -f /lib/systemd/system/systemd-update-utmp*', '', ' ---> Running in 5450319b692a', 'Removing intermediate container 5450319b692a']"}

The main error is : message: network teleport-network not found

Maybe I'm misusing docker_networks or network_mode, so here the snippet I'm using (I'm creating 3 containers like this one) :

platforms:
  - name: ubuntu-focal-proxy
    image: ubuntu:focal
    pre_build_image: false
    privileged: true
    command: ""
    cgroupns_mode: host
    tmpfs:
      - /run
      - /tmp
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
      - /var/lib/containerd
    docker_networks:
      - name: teleport-network
    network_mode: teleport-network
    exposed_ports:
      - 443/tcp
    groups:
      - all
      - proxy

If I understand the issue correctly, the step of creation of networks should be before the build. I've tested it locally and it works well. I'll send a PR for this issue.

Let me know if you need more information.

ehartmann referenced this issue in ehartmann/molecule-docker Nov 8, 2022
@ssbarnea ssbarnea transferred this issue from ansible-community/molecule-docker Jan 5, 2023
@ssbarnea ssbarnea added the docker label Jan 5, 2023
pbjhelmert added a commit to pbjhelmert/molecule-plugins that referenced this issue Oct 23, 2023
Else the build will attempt to use a network that hasn't been created
yet. This is essentially a resurrection of ehartmann's PR against
molecule-docker before its death.

Closes: ansible-community#24
Signed-off-by: Jake Helmert <jhelmert@pacificbiosciences.com>
zhan9san pushed a commit to pbjhelmert/molecule-plugins that referenced this issue Nov 13, 2023
Else the build will attempt to use a network that hasn't been created
yet. This is essentially a resurrection of ehartmann's PR against
molecule-docker before its death.

Closes: ansible-community#24
Signed-off-by: Jake Helmert <jhelmert@pacificbiosciences.com>
zhan9san pushed a commit to pbjhelmert/molecule-plugins that referenced this issue Nov 13, 2023
Else the build will attempt to use a network that hasn't been created
yet. This is essentially a resurrection of ehartmann's PR against
molecule-docker before its death.

Closes: ansible-community#24
Signed-off-by: Jake Helmert <jhelmert@pacificbiosciences.com>
pbjhelmert added a commit to pbjhelmert/molecule-plugins that referenced this issue Nov 13, 2023
Else the build will attempt to use a network that hasn't been created
yet. This is essentially a resurrection of ehartmann's PR against
molecule-docker before its death.

Closes: ansible-community#24
Signed-off-by: Jake Helmert <jhelmert@pacificbiosciences.com>
zhan9san pushed a commit that referenced this issue Nov 14, 2023
Else the build will attempt to use a network that hasn't been created
yet. This is essentially a resurrection of ehartmann's PR against
molecule-docker before its death.

Closes: #24

Signed-off-by: Jake Helmert <jhelmert@pacificbiosciences.com>
@ehartmann
Copy link
Author

Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants