1

Trying to open a port on an ubuntu 18.04 image and no luck Running RUN ufw allow 8080 returns

/bin/sh: 1: ufw: not found

Any ideas as to how I can open this port or run ufw commands?

2 Answers 2

2

Inside of a container, all ports are open by default to other containers on the same docker network. There is no need to run the ufw command, and it is not shipped in images since permissions to change the network are not granted by default (capability NET_ADMIN is not granted).

0

Taken from /bin/sh: 1: gvm: not found, which would say more or less:

Your shell is /bin/sh, but ufw expects /bin/bash, perhaps because it puts its initialization in ~/.bashrc.

Now the accepted answer says that it is not needed. If you still insist on running ufw, use

RUN ["/bin/bash", "-c", "ufw allow 8080"]

Or even better might be to put the commands you want to execute in a single bash script and add that to the image.

#!/bin/bash
set -e

ufw allow 8080

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.