How to attach an existent volume to a running container

< All Topics

Portainer is capable to attach a new volume to a running container and in this help article, you will learn how to do it.

Be advised that this operation destroys the running container and start a new one with the volume attached. Backup your data before doing this operation. 

How to attach an existent volume to a running container

Once you logged in Portainer, you need to go to Containers option and select the container that you want to attach a volume.

Click in Containers and select the container you want to manipulate.









The next step is doing a click in the Duplicate/Edit button.

Let's add a volume to this container.









Scroll down to the bottom to the page until the options for this container. Select Volumes and do a click in Map an Additional Volume button.

Scroll down to the bottom of this page.












The next thing is to type the path in the container, how you can see in this example, for an NGINX container, the path to persist is "/usr/share/nginx/html". Also, we need to specify the volume created.

Remember that you need to create the volume before this operation.









Is all look good, the only thing you need to is click in Deploy The Container button. You will receive the following warning:

Remember: The container is going to be destroyed, so, back up your files before this.








Is everything worked as expected, you will have a confirmation pop up.

This pop up confirms that the container was deleted and created a new one.









To confirm, click in your container, scroll down until you see volumes configuration. You will see something like this:

Now, the data of this NGINX is persistent.

Table of Contents