deanavenger
deanavenger

Reputation: 660

How to mount docker volumes to a folder on a network

I have docker installed on windows with a gitlab container running. Currently, I am mounting volumes to C drive but I want to mount the volumes to a folder on my network which is a server. My docker-compose file looks like this:

version: "3.6" 
services:
  web:
    image: 'gitlab/gitlab-ce'
    container_name: 'gitlab'
    restart: always
    hostname: 'localhost'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://localhost:9090'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    networks:
      - gitlab-network
    ports:
      - '80:80'
      - '443:443'
      - '9090:9090'
      - '2224:22'
    volumes:
      - 'C:\GitlabConfig:/etc/gitlab'
      - 'gitlab-logs:/var/log/gitlab'
      - 'gitlab-data:/var/opt/gitlab'

If whenever I want to create a backup then the backup should be stored in the folder on the network path. I want to store the backup on this path: \\power\Benutzer\hgul\GitlabConfig. Anyone has any idea if it is possible like that?

Upvotes: 2

Views: 2383

Answers (1)

Pitto
Pitto

Reputation: 8589

I suggest you to mount the network volumes on your system as local disks (or folder in a local disk) and then change your configuration to write on them.

One of the possible ways to achieve a similar result is adapting and using this command:

mklink /d "C:\GitlabConfig" "\\power\Benutzer\hgul\GitlabConfig"

Then your config will look like this:

volumes:
  - 'C:\GitlabConfig:/etc/gitlab'

Bonus

More solutions about mounting the network drive:
https://superuser.com/questions/244562/how-do-i-mount-a-network-drive-to-a-folder

Upvotes: 2

Related Questions