11.2. Starting a Container
Execute the following steps to start the container.
- Create a data container for RHGS container by executing the following command:
docker run --name glusterdata -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs:z -v /sys/fs/cgroup:/sys/fs/cgroup:ro <image name> /usr/sbin/setup.sh
# docker run --name glusterdata -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs:z -v /sys/fs/cgroup:/sys/fs/cgroup:ro <image name> /usr/sbin/setup.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:docker run --name glusterdata -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs:z -v /sys/fs/cgroup:/sys/fs/cgroup:ro rhgs3/rhgs-server-rhel7 /usr/sbin/setup.sh
# docker run --name glusterdata -v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd:z -v /var/log/glusterfs:/var/log/glusterfs:z -v /sys/fs/cgroup:/sys/fs/cgroup:ro rhgs3/rhgs-server-rhel7 /usr/sbin/setup.sh Script Ran Successfully
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
- The data container will be stopped once the script is run.
- SELinux labels are automatically reset to
svirt_sandbox_file_t
so that the container can interact with the Atomic Host directory. - In the above command, the following ensures that the gluster configuration are persistent.
-v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd -v /var/log/glusterfs:/var/log/glusterfs
-v /etc/glusterfs:/etc/glusterfs:z -v /var/lib/glusterd:/var/lib/glusterd -v /var/log/glusterfs:/var/log/glusterfs
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Execute the following command to run the container:
docker run -d --privileged=true --net=host --name <container-name> --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z <image name>
# docker run -d --privileged=true --net=host --name <container-name> --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z <image name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where,- --net=host option ensures that the container has full access to the network stack of the host.
- --volumes-from option is used to bind mount all the volumes from the data container.
/mnt/brick1
is the mountpoint of the brick in the atomic host and:/mnt/container_brick1
is the mountpoint of the brick in the container.- -d option starts the container in the detached mode.
For example:docker run -d --privileged=true --net=host --name glusternode1 --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z rhgs3/rhgs-server-rhel7
# docker run -d --privileged=true --net=host --name glusternode1 --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z rhgs3/rhgs-server-rhel7 5ac864b5abc74a925aecc4fe9613c73e83b8c54a846c36107aa8e2960eeb97b4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where, 5ac864b5abc74a925aecc4fe9613c73e83b8c54a846c36107aa8e2960eeb97b4 is the container ID. - If you want to use snapshot then execute the following command:
docker run -d --privileged=true --net=host --name <container-name> -v /dev:/dev --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z <image name>
# docker run -d --privileged=true --net=host --name <container-name> -v /dev:/dev --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z <image name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where, /mnt/brick1 is the mountpoint of the brick in the atomic host and :/mnt/container_brick1 is the mountpoint of the brick in the container.For example:docker run -d --privileged=true --net=host --name glusternode1 -v /dev:/dev --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z rhgs3/rhgs-server-rhel7
# docker run -d --privileged=true --net=host --name glusternode1 -v /dev:/dev --volumes-from glusterdata -v /mnt/brick1:/mnt/container_brick1:z rhgs3/rhgs-server-rhel7 5da2bc217c0852d2b1bfe4fb31e0181753410071584b4e38bd77d7502cd3e92b
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To verify if the container is created, execute the following command:
docker ps -a
# docker ps -a
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:docker ps -a
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5da2bc217c08 891ea0584e94 "/usr/sbin/init" 10 seconds ago Up 9 seconds glusternode1 1042bf93cf87 891ea0584e94 "/usr/sbin/setup.sh" 35 seconds ago Exited (0) 33 seconds ago glusterdata
Copy to Clipboard Copied! Toggle word wrap Toggle overflow