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?
How to Mount Local Directories using docker run -v. Using the parameter -v allows you to bind a local directory. -v or --volume allows you to mount local directories and files to your container. For example, you can start a MySQL database and mount the data directory to store the actual data in your mounted directory.
You can mount host volumes by using the -v flag and specifying the name of the host directory. Everything within the host directory is then available in the container. What's more, all the data generated inside the container and placed in the data volume is safely stored on the host directory.
Docker has an option to allow specific folders in a container to be mapped to the normal filesystem on the host. This allows us to have data in the container without making the data part of the Docker image, and without being bound to AUFS.
Though both methods are similar, there is a slight difference. Docker manages Volumes and is usually not affected by other processes running on the same host. In contrast, Bind Mounts are just directories on the host file system and may be modified by other processes other than docker.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With