I have a Dockerfile that includes some RUN
commands that starts up a mariadb server for a database import operation.
The problem is podman build
sets the network mode for the RUN
commands to host
by default, which uses the host's network interface - as I understood it from podman's documentation - so, when the mariadb step comes, the server can't start because there's another mariadb instance running on host with the same port - which I can't temporarily stop.
The workaround that worked for me is to add --network container
flag to the build
command but, doing this has prevented internet access for other steps that's installing dependencies with yum
, my guess is that the network namespace created for the build steps don't have external - internet - access.
So, it's sort of a deadlock, to install system dependencies in the image I'm building I have to use host network and, to start services that use network interface I have to use container network which can't access the internet - only with build
though, while run
ning containers with user defined bridge network the internet is accessible.
My workaround at the moment is to build twice once with host network and, the other with container network - second time build
uses the cached images where external dependencies are already installed - so, in such scenario it would be great if we can define which step in Dockerfile
or Containerfile
uses host network and which uses bridge network.
I apologize for the long elaboration of the issue and, I've tried to search for this particular case but, couldn't find any clear answer other than building each group of steps manually.
PS: I tried to set the network
flag to my user-defined network which works while running the container but, it's not supported - or I'm not sure how to do it with build
.
Late reply, but I had the same issue and was able to get around it by adding --network=private.