1

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?

Boots
  • 43
  • 2
  • 9

2 Answers2

0

After a short while off on another project, I have come back to learning docker. I am still unsure what was causing the errors. But when building the dockerfile I have been using a different name and tag, as I had deleted the image/container list. I can only assume it was a clash with a reserved word of some sort.

Boots
  • 43
  • 2
  • 9
0

I remember this just vaguely but still enough to set it down here, that you should not upgrade. && upgrade -y is just not needed since the image and the update should be all that is needed, else, you would rather install a higher version in that image right from the start, or take a higher version of the image. Therefore you have the image, that you choose a bag of versions that fit together, and upgrading can lead to version conflicts as in Error: Failed to synchronize cache for repo 'updates'.

questionto42
  • 7,175
  • 4
  • 57
  • 90