Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update software inside a docker container?

Tags:

docker

updates

I am very new to Docker and currently trying to get my head around if there is any best practice guide to update software that runs inside a docker container in a very large distributed environment. I already found couple of posts around updating a MySQL database in docker, etc. It gives a good hint for any software that stores data, but what if you want to update other parts or your own software package or services that are distributed and used by several other docker images through docker-compose?

Is there someone with real life experience doing that in such an environment who can help me or other newbies to understand the best practices in docker if there are any.

Thanks for your help!

like image 203
christian.vogel Avatar asked Sep 07 '15 16:09

christian.vogel


People also ask

How do you update a file inside a container?

To verify, use the cat command to print the contents inside the file. In this way, you can use any editor of your choice to edit files inside the container. If you already have a container running in the background, you can even use the Docker exec command to get access to the bash of the container.

Can you update a Docker container?

Run the new container with the docker run command and the name and the tag of the updated image that the container will need. In this example, the -it flag tells Docker to run the container in interactive mode, so you can run commands inside the container to verify any updated functionality.

Can I install software in Docker container?

Do not install software in /workdir in the Docker container, as the /workdir is a directory mounted from the host system. (It is the /workdir/<userID> directory on the host). Sometime, a software could take a long time to install. If your internet connection got interrupted in the middle when installing a software.


1 Answers

You never update software in a running container. You pull down a new version from the hub. If we assume you're using the latest tag (which is a bad idea, always pin your versions) of your image and it's one of the official library images or the publicly available that uses automated builds you'll get the latest version of the container image when you pull the image.

This assume you've also separated the data out of your container either as a host volume or using the data container pattern.

The container should be considered immutable, if you change it's state it's no longer a true version of the image.

like image 155
booyaa Avatar answered Sep 30 '22 18:09

booyaa