You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing email@example.com.
We are experiencing playback issues from our video hosting provider. Please check back shortly.
Configuring a Container
In this lesson, we'll take our container knowledge one step further and learn about additional commands for managing containers.
Transcript(open in window)
[00:00] In the previous lesson, we learned how to manage the lifecycle of our containers and pull the official Ignition image. In this lesson, we'll expand that knowledge and provide some additional configuration for our Gateway container. I mentioned earlier that containers are immutable and a new one must be created if we want to make any changes. Since containers are isolated from other processes and other containers, any of the changes made within the container are lost once it's removed. To get around this issue and persist our data we can use volumes. Volumes allow us to connect file paths within the container back to the host machine. So if we make any changes in the directory associated with that volume, it will be saved for any future containers that also mount to it. Let's add a volume to our container so that we can save our gateway'ss data. To create a volume we can type in "docker volume create". Next we can specify a name for our volume like "gateway -data".
[01:04] And then we can hit enter. If we run "docker inspect" on the volume, we can see more information about it, like the mount point. We can display our list of volumes with "docker volume ls". And if we want to remove one, we can type "docker volume rm" and the volume name. Let's type out another "docker run" command. Let's start by adding the same options as before. Then to attach a volume we can add "-v" and the name of our volume "gateway-data" and then where it will be mounted in our container. So, add ":/ usr/local/bin /ignition/data". Finally, let's add the Ignition image and quickly review.
[02:07] We started by adding options for detached mode and our port mapping. Last time we separated the two options, "-d" and "-p", but just know that you can also combine them to simply "-dp". We've added a volume with the "v" option and this is mounted to the Ignition data folder. Anything that gets added to or modified within that folder will be saved within the volume. Let's hit enter and spin it up. Let's log into our Gateway webpage and make a configuration change to test our new volume. I'll select the Standard Edition of Ignition, agree to the software license agreement, and configure a user login. I'm just going to use admin password. And then we can start the Gateway. Let's go to our config page. We'll log in real quick.
[03:06] And let's add a device connection. Let's select a Programmable Device Simulator. And we can give it a generic name of "Simulator". Let's say that we want to change the max memory for our JVM. We'll have to remove this container and create a brand new one. If we go back to our command line we can grab our container ID. We can stop the container. And then remove it. We can set the max memory for the jvm by passing runtime arguments to the container. There are a few runtime arguments that we can pass and you can see those on the "Docker Image" user manual page. While we're setting the max memory, let's also specify a Gateway name. These arguments get added to the "run" command after the image name.
[04:02] I'll arrow up and find the last "docker run" command we ran. And then to add a Gateway name we can add "-n" and we can call this "docker-test". And then for the max memory we can add "-m". And then type "2048" for the number of megabytes. Let's hit enter and start it up and go to our Gateway web page. You'll notice that we didn't have to go through the commissioning stage again, and at the top of the page, we can see the name of our Gateway, "docker- test". Let's double check the max memory, which we can see on the performance status page. And we see that the max memory is two gigs. Finally, let's look at our device connections. And here's our "Simulator" device. If we hadn't added our volume to the container.
[05:04] This device connection would have been lost when the container was rebuilt. We'll stop here now that we've learned about more useful ways to configure our containers. In the next lesson, we'll take a look at a new tool, Docker Compose, which allows us to set up an application with multiple containers and we'll get one step closer to building out an Ignition solution with Docker.