Creating Docker Containers with storage attached automatically

To create docker containers with storage attached automatically

In the procedure, demovol is the name of the created volume.

  1. Create a volume using the docker volume create command.

    # docker volume create -d veritas --name demovol

  2. Alternatively, you can also specify size and or layout options using -o option.

    # docker volume create -d veritas --name demovol -o size=1g -o layout=mirror

    Note:

    If options are not provided while creating a volume, then it uses default values for size and layout that are stored in the /etc/vx/docker/vxinfoscale-default.conf file. If layout=auto is mentioned, then InfoScale automatically chooses the best layout for the environment.

  3. You can verify whether the volume is created properly by running the a docker volume ls command.

    # docker volume ls

    DRIVER    VOLUME NAME
    veritas   demovol
  4. You can verify the detail information of the volume using docker volume inspect command.

    # docker volume inspect demovol

    [
    {
    "Name": "demovol",
    "Driver": "veritas",
    "Mountpoint": "/dockerfs/demovol_dockerdg",
    "Labels": {},
    "Scope": "global"
    }
    ]
  5. Launch docker container.

    # docker run --name <container_name> -it --volume-driver veritas -v demovol:/vol<docker_image> <command>

    Where, VxVM volume 'demovol' gets automatically attached to the docker container.

  6. You may verify that the container is running and accessible.

    # docker ps <container_name>

  7. You can also remove the volume if it is not needed anymore.

    # docker volume rm demovol