Running a Container
To run a Container:
Run the image and create a new container using a run command as shown below:
# docker run --net=host --volume ~/bxlogs:/zixi_broadcaster-centos7-transcoder/logs --volume ~/bxfiles:/zixi_broadcaster-centos7-transcoder/files --name Broadcaster_13.1.38986 --publish 4444:4444/TCP --publish 2088:2088/UDP zixi_broadcaster:13.1.38986
The run command has many options. Below is a description of the options used in this example:--net
– This option allows you to choose the type of networking used in the container.With “host” mode all containers on the host share the hosts networking configuration and to access a container you would use the host’s IP address, such as 192.168.10.20:4444 for the Broadcaster UI. If you have multiple Broadcaster containers running on the same host you would need to configure the Broadcaster in each container to use a different port for the UI and different ports for Zixi or other input and output protocols. Also, you will need to configure the firewall on the host to protect the running containers from external threats.
With “bridged” mode, which is the default if you do not specify the --net option, each container will have its own network that exists on host. The host will be able to directly communicate with the containers but any other device on the network cannot communicate with the containers unless IP forwarding is enabled. See this link for more information on IP forwarding on the host. Networking in bridged mode will be slightly less efficient than host mode because there is an additional layer of networking software.
--volume
– This option allows you to mount directories inside the container to directories on your host system. In this example we are mounting the logs directory and the files directory from the Broadcaster installation directory to local folders which makes it easy to inspect logs or retrieve recordings from the Broadcaster running in the container.--name
– This option gives the container a human readable name when looking at the Docker process table.--publish
– This option is only valid with Bridged mode networking. In the dockerfile you will see that we exposed typical ports that you would use with the Broadcaster. However, those ports will only be opened up to the host if you also publish them in the run command. For host mode networking, all network settings are controlled on the host itself and --publish is ignored.Image ID – The last option is the image ID which you see in the images table above.
Upon using the Docker run command, there will now be a running Docker container.
You can see the list of all running containers using the following command:
# docker ps
The output will be similar to the following (with different IDs):
|
|
|
|
|
|
|
---|---|---|---|---|---|---|
|
|
|
|
|
|
|
In host mode the ports will be empty. In bridged mode the actual ports that were published will be shown. In the shell window where you issued the docker run command you will see any content going to STDOUT and STDERR inside the container on STDOUT of the docker run process on the host.
3. With the container runnig, you can log into the Broadcaster web UI at port 4444. In host mode you will use the IP address of the host itself. In bridged mode you can use a command like the following to see the IP address of the running container:# docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)