-2

I have installed docker and have a container in it.

$ docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Sun, 16 Sep 2018 13:21:33 +1000
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Sun Sep 16 03:21:33 2018
  OS/Arch:          linux/amd64
  Experimental:     false


$ docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 2
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 
runc version: N/A 
init version: v0.18.0 
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.18.0-3-amd64
Operating System: Debian GNU/Linux buster/sid
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.659GiB
Name: debian
ID: 
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

I have forgotten how to update the container.

Edit : I meant update the image.

  • 1
    One doesn't normally update a container, they update the image instead. – Centimane Dec 7 '18 at 17:12
0

Update container image

If you need to update the container's image/software this is fairly straight forward as long as your docker container does not store application data. E.g your production database is not kept on the docker container, or your website content. You will need to make sure you have built your container's appropriately before doing this.

I have referenced this blog post and this stack exchange post. Please review them before trying these steps.

First you need to know what your container's application is. E.g. nginx, mysql, apache2, etc. Then run the following:

docker pull [application]

This pulls the latest version of that application. In the linked blog post they wanted a specific version of nginx so to do that you can look up available docker images by doing this:

docker images | grep nginx 
docker pull nginx:alpine   

Substitute nginx for whatever your software is and alpine is the version of nginx they wanted so you can change this as it applies.

Once you have pulled the updated software image down you can run the following to update your container:

docker stop [CONTAINER]
docker rm [SAME CONTAINER AS BEFORE]
docker run --name [NEW CONTAINER NAME] \
  [OPTIONS] \
  [CONFIGURATIONS] \
  [ADDITIONAL SETTINGS] \
  -d [SOFTWARE, e.g. nginx or mysql]

Now you should have a new container set up with new software and running with the options you want. Make sure to read over all the links I have provided before attempting any of these commands. Again, if you keep production data inside your container you cannot follow these steps. You must backup your data and consider creating a volume that your container can mount and have access to instead.

I will also include a link to the relevant Docker documentation regarding this task.

Please comment if you have any questions or issues with this answer. I appreciate feedback to correct any misconceptions and to improve my posts. I can update my answer as needed.

Best of Luck!

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.