vinay
vinay

Reputation: 1034

Upgrade docker container to latest image

We are trying to upgrade docker container to latest image.

Here is the process i am trying to follow.

  1. Let's say i have already pulled docker image having version 1.1
  2. Create container with image 1.1
  3. Now we have fixed some issue on image 1.1 and uploaded it as 1.2
  4. After that i wanted to update container running on 1.1 to 1.2

Below are the step i thought i will follow.

  1. Pull latest image
  2. Inspect docker container to get all the info(port, mapped volume etc.)
  3. Stop current container
  4. Remove current container
  5. Create container with values got on step 2 and using latest image.

The problem I am facing is i don't know how to use output of "Docker Inspect" command while creating container.

Upvotes: 1

Views: 4734

Answers (1)

Farhad Farahi
Farhad Farahi

Reputation: 39237

What you should have done in the first place:

In production environments, with lots of containers, You will lose track of docker run commands. In order to keep up with complexity, Use docker-compose.

First you need to install docker-compose. Refer to official documents for that.

Then create a yaml file, describing your environment. You can specify more than one container (for apps that require multiple services, for example nginx,php-fpm and mysql)

Now doing all that, When you want to upgrade containers to newer versions, you just change the version in the yaml file, and do a docker-compose down and docker-compose up.

Refer to compose documentation for more info.

What to do now:

Start by reading docker inspect output. Then gather facts:

  • Ports Published. (host and container mapping)
  • Networks used (names,Drivers)
  • Volumes mounted. (bind/volume,Driver,path)
  • Possible Run time command arguments
  • Possible Environmental variables
  • Restart Policy

Then try to create docker-compose yaml file with those facts on a test machine, and test your setup.

When confident enough, Roll it in production and keep latest compose yaml for later reference.

Upvotes: 2

Related Questions