portainer-docker-jack-tutorial-may
Image: Pichsakul/Adobe Stock

Portainer has very quickly become my favorite Docker container management system. With this platform, there’s little you cannot do, such as deploy containers, and create and manage networks, volumes, secrets and full-stack applications.

Another cool trick Portainer has up its sleeve is the ability to create new images based on running containers. This is a handy feature if you deploy a customized container and wish to be able to replicate that container quickly and repeatedly. This can save serious time and effort for your Docker deployments.

I want to show you just how easy it is to use Portainer to create a new image, based on a running container. One thing to keep in mind is the new images will be saved on the local repository. Even if you connect Portainer to your Docker Hub registry, creating these images does not push them to Docker Hub (I’m working to try and find a solution for this). However, you can add users to Portainer so your entire team will have access to the images and containers found within.

With that said, let’s create an image.

SEE: Hiring kit: Back-end Developer (TechRepublic Premium)

What you’ll need

To follow along with this tutorial, you’ll need a running instance of Portainer and that’s it. If you’ve not already deployed Portainer, you can find out how in “How to deploy the Portainer container management tool with persistent storage.” Let’s get to work.

How to create a new image from a running container

Lot into Portainer and then click Containers from the left sidebar. In the resulting window (Figure A), click the container name from which you want to create the new image.

Figure A

portimagea
Image: Jack Wallen/TechRepublic. I have already deployed a few containers with Portainer.

In the resulting window, scroll down to the Create image section (Figure B).

Figure B

portimageb
Image: Jack Wallen/TechRepublic. Creating a new image from a running container is simple with Portainer.

You must give the image a name. If you don’t specify a tag, latest will be used. Let’s give our image the name and tag myimage:may18. Type that in the Image filed and then click Create. This will create a new image, based on the chosen container.

How to locate your new image

Click Images from the left sidebar. You should see the image listed that is tagged myimage:may18 (Figure C).

Figure C

portimagec
Image: Jack Wallen/TechRepublic. Our newly created image is ready to go.

Click the name of that image to view all of the details (Figure D).

Figure D

portimaged
Image: Jack Wallen/TechRepublic. The details of our newly created image.

How to deploy a container based on our new image

Now, it’s time to create an image with our container. Click Containers in the left sidebar and then click Add container. In the resulting window (Figure E), give the new container a name and then type myimage:may18 in the image field.

Figure E

portimagee
Image: Jack Wallen/TechRepublic. Creating a new container, based on our new image.

Since we’re just creating a simple deployment, that’s all we need to add for the configuration. Click Deploy the container and Portainer will do its thing. You should be quickly returned to the container list, where you’ll see our new container running (Figure F).

Figure F

portimagef
Image: Jack Wallen/TechRepublic. Our new container, based on our new image, has been successfully deployed.

You’ve successfully created an image from a running container and then deployed a new container based on that image. Isn’t technology fun?

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays