Creating and attaching a volume to the hcl-compass Docker container
This quick start guide shows you how to create and attach a volume to the hcl-compass Docker container.
Before you begin
Note: Using HCL Compass on Docker and Docker Compose is
not supported when deployed in a production environment. To use HCL Compass in a container in a production
environment, deploy HCL Compass to a
Kubernetes environment.
To access
hcl-compass container files, information
such as log files and configuration files outside of the container, we can create and attach a
volume to the hcl-compass container or
create bind mounts. Volumes are the preferred mechanism for persisting data generated by and
used by Docker containers. Using volume or bind mounts allows you to monitor all log and
configuration files. You can also remove data from the hcl-compass container itself so that the container
can be cleanly shut down and destroyed at any time without any data loss. If a new hcl-compass container is created to replace the
old one, you can connect the new container to the same data store or bind it to the same
disk.For more information, see Deploying HCL Compass on SoFy Sandbox.
About this task
Procedure
-
Create a volume called compass-rest-server.
$ docker volume create compass-rest-server compass-rest-server
-
List the volumes.
$docker volume ls DRIVER VOLUME NAME local compass-rest-server
-
Inspect the compass-rest-server volume.
$ docker volume inspect compass-rest-server [ { "CreatedAt": "2020-04-30T13:41:26-04:00", "Driver": "local", "Labels": {}, "Mountpoint": "/var/lib/docker/volumes/compass-rest-server/_data", "Name": "compass-rest-server", "Options": {}, "Scope": "local" } ]
-
Attach the compass-rest-server volume to the hcl-compass-server container by using the
docker run
command.-v compass-rest-server:/opt/hcl/compass/compass-rest-server-distribution/
Note: If you are using bind mounts instead of volumes, add the following during thedocker run
command:-v /home/your_local_folder:/opt/hcl/compass/compass-rest-server-distribution