I am building my first dockerfile and need to install some packages. Presently I am using Fedora and the first thing I would like to do is run dnf update && upgrade, but I get an error.
Dockerfile:
# Base image
FROM fedora:28
LABEL description="Intellij community edition 2018"
# Update and Upgrade
RUN dnf update && upgrade -y
Error:
Error: Failed to synchronize cache for repo 'updates'
The command '/bin/sh -c dnf update && upgrade -y' returned a non-zero code: 1
I have tried with both dnf and yum, and also used ubuntu as a base image so I could try with apt-get, but I keep getting a different but similar Error:
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
/bin/sh: 1: upgrade: not found
The command '/bin/sh -c apt-get update && upgrade -y' returned a non-zero code: 127
I have already tried the solution to these questions, but neither worked:
The command '/bin/sh -c returned a non-zero code: 127
How to install multiple packages using apt-get via a Dockerfile
The only way I can get this to run is by building manually from an empty container using the -net=host argument.
Is it even possible to install, update or upgrade packages directly from the docker file, and if so how?