Skip to contentSkip to conversation

tests/docker: Allow passing --network option when building images

RFC PATCH In review Philippe Mathieu-Daudé 3 participants 7 messages Jan 19, 2021

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 tests/docker: Allow passing --network option when building images

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been ignored, or old ones used instead.
  Traceback (most recent call last):
    File "./tests/docker/docker.py", line 709, in <module>
      sys.exit(main())
    File "./tests/docker/docker.py", line 705, in main
      return args.cmdobj.run(args, argv)
    File "./tests/docker/docker.py", line 498, in run
      dkr.build_image(tag, docker_dir, dockerfile,
    File "./tests/docker/docker.py", line 353, in build_image
      self._do_check(build_args,
    File "./tests/docker/docker.py", line 244, in _do_check
      return subprocess.check_call(self._command + cmd, **kwargs)
    File "/usr/lib64/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  make: *** [tests/docker/Makefile.include:61: docker-image-debian10] Error 1

Fix by passing the NETWORK variable with --network= argument.

---
 tests/docker/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
tests/docker/Makefile.include +1 -0
index bdc53ddfcf9..b65fd684011 100644
@@ -63,6 +63,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
 		$(if $V,,--quiet) \
 		$(if $(NOCACHE),--no-cache, \
 			$(if $(DOCKER_REGISTRY),--registry $(DOCKER_REGISTRY))) \
+		$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--network=$(NETWORK))) \
 		$(if $(NOUSER),,--add-current-user) \
 		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
 		$(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
Signature · 1 line
2.26.2
#1 lore raw
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

Quoted 27 lines

Traceback (most recent call last):
File "./tests/docker/docker.py", line 709, in <module>
sys.exit(main())
File "./tests/docker/docker.py", line 705, in main
return args.cmdobj.run(args, argv)
File "./tests/docker/docker.py", line 498, in run
dkr.build_image(tag, docker_dir, dockerfile,
File "./tests/docker/docker.py", line 353, in build_image
self._do_check(build_args,
File "./tests/docker/docker.py", line 244, in _do_check
return subprocess.check_call(self._command + cmd, **kwargs)
File "/usr/lib64/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
make: *** [tests/docker/Makefile.include:61: docker-image-debian10] Error 1

Fix by passing the NETWORK variable with --network= argument.

---
 tests/docker/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
tests/docker/Makefile.include +0 -0
index bdc53ddfcf9..b65fd684011 100644

tests/docker/Makefile.include docker-image-%: $(DOCKER_FILES_DIR)/%.docker · line 67

Quoted 5 lines
tests/docker/Makefile.include +1 -0
@@ -63,6 +63,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
 		$(if $V,,--quiet) \
 		$(if $(NOCACHE),--no-cache, \
 			$(if $(DOCKER_REGISTRY),--registry $(DOCKER_REGISTRY))) \
+		$(if $(NETWORK),$(if $(subst
 $(NETWORK),,1),--network=$(NETWORK))) \

which if it has we'll need to tweak both build and run steps?

Quoted 3 lines
tests/docker/Makefile.include +0 -0
 		$(if $(NOUSER),,--add-current-user) \
 		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\

$(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\

Signature · 1 line
Alex Bennée
#2 lore raw
Quoted 19 lines · Alex Bennée
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.
Quoted 8 lines

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

No idea as I'm not following their development, but TBH it becomes harder and harder to use without tricks (I had to add systemd.unified_cgroup_hierarchy=0 to kernel cmdline to keep using it).

Maybe I should switch to podman which is the recommended engine on Fedora.

Cc'ing Marc-André who added podman support (Daniel is in Cc).

Quoted 23 lines
Quoted 23 lines

Traceback (most recent call last):
File "./tests/docker/docker.py", line 709, in <module>
sys.exit(main())
File "./tests/docker/docker.py", line 705, in main
return args.cmdobj.run(args, argv)
File "./tests/docker/docker.py", line 498, in run
dkr.build_image(tag, docker_dir, dockerfile,
File "./tests/docker/docker.py", line 353, in build_image
self._do_check(build_args,
File "./tests/docker/docker.py", line 244, in _do_check
return subprocess.check_call(self._command + cmd, **kwargs)
File "/usr/lib64/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
make: *** [tests/docker/Makefile.include:61: docker-image-debian10] Error 1

Fix by passing the NETWORK variable with --network= argument.

---
 tests/docker/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

tests/docker/Makefile.include docker-image-%: $(DOCKER_FILES_DIR)/%.docker · line 67

Quoted 10 lines
tests/docker/Makefile.include +1 -0
index bdc53ddfcf9..b65fd684011 100644
@@ -63,6 +63,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
 		$(if $V,,--quiet) \
 		$(if $(NOCACHE),--no-cache, \
 			$(if $(DOCKER_REGISTRY),--registry $(DOCKER_REGISTRY))) \
+		$(if $(NETWORK),$(if $(subst
 $(NETWORK),,1),--network=$(NETWORK))) \

which if it has we'll need to tweak both build and run steps?

I suppose you need need networking for git (submodule) clone?

Personally I don't require networking when running because I share my QEMU source directory as a volume, so it never bothered me.

Quoted 6 lines
Quoted 4 lines
tests/docker/Makefile.include +0 -0
 		$(if $(NOUSER),,--add-current-user) \
 		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\

$(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\

#3 lore raw
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Alex Bennée
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.
Quoted 8 lines

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

No idea as I'm not following their development, but TBH it becomes harder and harder to use without tricks (I had to add systemd.unified_cgroup_hierarchy=0 to kernel cmdline to keep using it).

Quoted 4 lines

Maybe I should switch to podman which is the recommended engine on Fedora.

Cc'ing Marc-André who added podman support (Daniel is in Cc).

I'm using podman exclusively since Docker doesn't work well with modern distros that use Cgroups v2.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
Quoted 35 lines · Daniel P. Berrangé
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Alex Bennée
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.
Quoted 8 lines

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

No idea as I'm not following their development, but TBH it becomes harder and harder to use without tricks (I had to add systemd.unified_cgroup_hierarchy=0 to kernel cmdline to keep using it).

Quoted 7 lines
Quoted 4 lines

Maybe I should switch to podman which is the recommended engine on Fedora.

Cc'ing Marc-André who added podman support (Daniel is in Cc).

I'm using podman exclusively since Docker doesn't work well with modern distros that use Cgroups v2.

OK this probably explains it.

Ideally we could add a check for this ("modern distro" -> docker engine not recommended) but I guess I'm the only one using this feature on Fedora (as nobody complained) so not a problem. I'll see how to use podman.

Thanks,

Phil.

#5 lore raw
Quoted 44 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Daniel P. Berrangé
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Alex Bennée
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.
Quoted 8 lines

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

No idea as I'm not following their development, but TBH it becomes harder and harder to use without tricks (I had to add systemd.unified_cgroup_hierarchy=0 to kernel cmdline to keep using it).

Quoted 7 lines
Quoted 4 lines

Maybe I should switch to podman which is the recommended engine on Fedora.

Cc'ing Marc-André who added podman support (Daniel is in Cc).

I'm using podman exclusively since Docker doesn't work well with modern distros that use Cgroups v2.

Quoted 6 lines

OK this probably explains it.

Ideally we could add a check for this ("modern distro" -> docker engine not recommended) but I guess I'm the only one using this feature on Fedora (as nobody complained) so not a problem. I'll see how to use podman.

I'm not sure we need to block it. If someone has docker installed then its reasonable to assume they have ti working. We prefer podman if both are installed.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
Quoted 47 lines · Daniel P. Berrangé
Quoted 46 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Daniel P. Berrangé
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Alex Bennée
Quoted 16 lines · Philippe Mathieu-Daudé

When using the Docker engine, build fails because the container is unable to resolve hostnames:

  $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
    BUILD   debian10
  #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
  #6 9.679   Temporary failure resolving 'deb.debian.org'
  #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates InRelease
  #6 16.69   Temporary failure resolving 'security.debian.org'
  #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
  #6 22.69   Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
  #6 22.74 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
  #6 22.74 W: Some index files failed to download. They have been
  ignored, or old ones used instead.
Quoted 8 lines

I'm confused by this one as it currently works for me. That said I thought the actual behaviour was meant to be networking is enabled by default and explicitly disabled by the run step (which shouldn't be pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

No idea as I'm not following their development, but TBH it becomes harder and harder to use without tricks (I had to add systemd.unified_cgroup_hierarchy=0 to kernel cmdline to keep using it).

Quoted 7 lines
Quoted 4 lines

Maybe I should switch to podman which is the recommended engine on Fedora.

Cc'ing Marc-André who added podman support (Daniel is in Cc).

I'm using podman exclusively since Docker doesn't work well with modern distros that use Cgroups v2.

OK this probably explains it.

Quoted 8 lines
Quoted 4 lines

Ideally we could add a check for this ("modern distro" -> docker engine not recommended) but I guess I'm the only one using this feature on Fedora (as nobody complained) so not a problem. I'll see how to use podman.

I'm not sure we need to block it. If someone has docker installed then its reasonable to assume they have ti working. We prefer podman if both are installed.

From my point of view podman is the odd man out (I run upstream docker.com packages on Debian Buster). I had to jump through some hoops to get podman installed on my Gentoo box but I think it's currently broken because it's Gentoo.

IOW I assume the people that really care about podman will shout if it breaks. It would be nice if we could catch cases in the CI though.

Quoted 4 lines

Regards,
Daniel

Signature · 1 line
Alex Bennée