1

I'm trying to create a Dockerfile for an Arch Linux image with iptables-nft installed. If I run the archlinux Docker image interactively and then pacman -Syu iptables-nft, I get asked iptables-nft-1:1.8.10-2 and iptables-1:1.8.10-2 are in conflict. Remove iptables? [y/N] and Proceed with installation? [Y/n]. Answering yes to both of those questions does what I want.

The problem comes when I try to script that in the Dockerfile, where I can't interactively answer those questions. My first attempt was RUN pacman --noconfirm -Syu iptables-nft, but this doesn't work because --noconfirm means to go with the default answer, and the default answer to the first question is no. Then I tried removing iptables first before installing iptables-nft, but iproute2 depends on either iptables or iptables-nft, and base depends on iproute2.

This leaves me with a few approaches which technically work, but all of which leave me with concerns:

  1. RUN yes | pacman -Syu iptables-nft works, but blindly saying y to any question pacman ever asks would break if it ever asks a non-yes-no question, and if it ever asks any default-no questions other than "Remove iptables?", it would probably be bad to blindly answer yes to them too.
  2. RUN pacman --noconfirm -Rdd iptables && pacman --noconfirm -Syu iptables-nft works, but if iptables ever gets any dependencies that iptables-nft doesn't also satisfy, it would leave me with a broken system, and if there are any packages that were only installed because the old iptables needed them, they'll get left behind indefinitely.
  3. RUN pacman --noconfirm -Rsdd iptables && pacman --noconfirm -Syu iptables-nft works, but it has the same broken system risk as #2 does, and it also uninstalls a bunch of other packages only to immediately reinstall them.

Is there a better solution than any of the above? Ideally, I'd like just a pacman equivalent of dnf swap, but I can't find any such thing.

1 Answer 1

2

Today I needed absolutely the same thing.

On this page: https://gitlab.archlinux.org/pacman/pacman/-/issues/60

I found a simple solution to this.  Just run it with the parameter --ask=4.  See below:

pacman --noconfirm --ask=4 -Syu iptables-nft

Worked for my Dockerfile with a similar pacman command.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.