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

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.

About this task

Procedure

  1. Create a volume called compass-rest-server.
    $ docker volume create compass-rest-server  
    compass-rest-server  
  2. List the volumes.
    $docker volume ls  
    DRIVER              VOLUME NAME  
    local               compass-rest-server  
  3. 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"  
        }  
    ]  
  4. 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 the docker run command:
    -v /home/hcluser/your_local_folder:/opt/hcl/compass/compass-rest-server-distribution