How to mount a host directory in a Docker container

后端 未结 25 1616
庸人自扰
庸人自扰 2020-11-22 12:43

I am trying to mount a host directory into a Docker container so that any updates done on the host is reflected into the Docker containers.

Where am I doing somethin

25条回答
  •  独厮守ぢ
    2020-11-22 13:23

    You can also do this with Portainer web application for a different visual experience.

    First pull the Portainer image:

    docker pull portainer/portainer
    

    Then create a volume for Portainer:

    docker volume create portainer_data
    

    Also create a Portainer container:

    docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
    

    You will be able to access the web app with your browser at this URL: "http://localhost:9000". At the first login, you will be prompted to set your Portainer admin credentials.

    In the web app, follow these menus and buttons: (Container > Add container > Fill settings > Deploy Container)

    I had trouble to create a "mount" volume with Portainer and I realized I had to click "bind" when creating my container's volume. Below is an illustration of the volume binding settings that worked for my container creation with a mounted volume binded to the host.

    P.S.: I'm using Docker 19.035 and Portainer 1.23.1

提交回复
热议问题