-
Notifications
You must be signed in to change notification settings - Fork 5
Managing Docker Containers
The SNP Prototype has a number of docker containers to assist in facilitating starting up the program easily in any environment. This makes it much easier than following a long script of instructions for setting up several separate servers.
The current Docker images that are directly used (and not transitively - we use more containers under the covers) are:
- MongoDB Container - This is the Mongo Database running on Ubuntu Server, bootstrapped with a small amount of data for querying upon. (code for creating this Docker container can be found here)
- Application Container - This is the Tomcat application container running on CentOS with the most current version of our code and configuration set up for connecting to the MongoDB Container (code for this Docker container is housed here)
- MongoDB Console - The Mongo shell, which has been sandboxed within a CentOS which has a number of JavaScript files to show performance differences of different types of queries. (The code for creating this Docker container can be found here.
The easiest way to use these is to follow the Quickstart instructions, however, this entry should detail in more specifics how to use these containers.
To see running containers, execute the following command:
docker ps
To see all containers (including stopped ones), execute the following command:
docker ps -a
There are two main types of ways to start up a docker image.
The most common way is to fire it up and let it do the default commands that are built into the image and to let the process run as a daemon. This will be used most of the time. The command should follow the following format:
docker run --rm -d -p<Port Mappings> --name<Name for Process> <DockerHub Username>/<Image Name>
For example, to fire up the mongoDB image, you would type the following command:
docker run -d -p 27017:27017 --name snp-mongodb jlgrock/snp-prototype-mongodb
When editing an image, however, you will want to fire it up in edit mode so that the image is interactive and remembers the commands that you give it, in the case that want to save them off to another incremental image.
To fire it up into interactive mode, run the following:
docker run -i -t -p 27017:27017 --name snp-mongodb jlgrock/snp-prototype-mongodb /bin/sh
For example, in the case of the mongodb image, you would type the following:
docker run -i -t -p 27017:27017 --name snp-mongodb jlgrock/snp-prototype-mongodb /bin/sh
Please note that the command to start the database (supervisord -c /etc/supervisor.conf) has not been run, and this will have to be done manually if you want to access the database.
Once you have finished using the docker process, you can kill it and it will destroy all of the current changes that have been made to the process. This includes data stored in the database.
By default, Docker will leave a process around for inspection. You are required to manually clean it up yourself. By adding the --rm flag to the docker run command, it will automatically clean it up after it has been killed. However, this isn't compatible with running the -d flag (which runs the process in detached mode). So, you'll likely have to clean up an image or two eventually. The command follows the following format:
docker rm <Container Name>
You can find the Container Names by looking at all of the processes
In general, this is not all you can do with Docker containers, but attempts to cover the basics necessities for general usage. For more information about Docker containers, please visit https://docs.docker.com/