17

I use GitLab CI Runner, it uses the command:

docker run -d --name postgres postgres:9.4

I want to do something like this:

docker run -d --name postgres --volumes-from postgres_datastore postgres:9.4

But GitLab CI Runner doesn't support any options (-v or --volumes-from).

Is there any other way?

Erik Dannenberg
  • 5,716
  • 2
  • 16
  • 21
Eric
  • 245
  • 1
  • 3
  • 8
  • 1
    I have similar issue. Spent the whole day in Gitlab runner ci/cd trying to find out how I can mount src:target volumes onto an IMAGE:my-bespoke-image that I am using in my gitlab runner script. No where closer to finding out. Have upvoted your question – user1561783 Apr 12 '22 at 14:02

1 Answers1

20

The Docker volumes-from option is not yet available in Gitlab CI Runner (see this PR), however you can configure host mounts and volumes:

[runners.docker]
  volumes = ["/host/path:/target/path:rw", "/some/path"]

The above example would mount /host/path at /target/path/ inside the container and also create a new volume container at /some/path.

See the Gitlab CI Runner manual for all docker related options.

Edit:

For service containers it seems you can only define volumes via the dockerfile of the service image. Maybe enough depending on your requirements.

Erik Dannenberg
  • 5,716
  • 2
  • 16
  • 21
  • 1
    Your example would mount path inside general runner-container (not container with postgres-service). – Eric Apr 14 '16 at 11:45
  • Correct, your question was a bit misleading. I updated the title and answer, hopefully clearer now. – Erik Dannenberg Apr 14 '16 at 23:28
  • 2
    In Gitlab CI Runner - where would that snippet detailing [runners.docker] ..... etc. Where would it go ? And, would those volumes be mounted on the image running from IMAGE: etc. etc. in our .gitlab-ci.yml script ? – user1561783 Apr 12 '22 at 14:04