Warm tip: This article is reproduced from serverfault.com, please click

Is updating a package inside a docker the way to go?

发布于 2021-04-23 13:11:19

I have been fiddling with Docker recently and trying this image. I just learnt what ENTRYPOINTs are and several new command for Docker but then I thought: What if I wanted to update the NMAP version of that image? I went ahead and tried apt stuff, then I realised it's build on Alpine, wchich uses apk and found out it is not installed, and I couldn't figure out why.

Maybe the owner of this images deleted it? If so, should I be able to perform updates on packages installed, or is that the image maintainer's task?

Questioner
miyo9190
Viewed
0
moonkotte 2021-04-23 21:54:46

As it can be seen in dockerfile of image you shared, it has alpine linux image as a base image and doesn't have any removal steps of apk. Also it has two arguments at the beginning of a dockerfile which then are used for installing the nmap within this image:

ARG nmap_ver=7.91

ARG build_rev=4

Which means you can download this Dockerfile, change version in this Dockerfile locally to which one you want to have, then build an image:

docker build -t nmap_myversion .

And then run a container with your own image:

docker run -d --name my_nmap nmap_myversion

To answer your question updating software in already created image is not a good approach because it will create a new layer in your docker container which will be lost after a container deletion. Best option is to have this done in the image. Good example is how this nmap image is created (see Dockerfile above)