Docker is a tool that allows developers to easily deploy an application in a sandbox called a container. This sandbox provides a specified Operating Sytem, and it provides a file system, libraries and applications.
You can install Docker by following the instructions here.
After you have installed Docker, you are ready to create containers. To do this, you need to obtain the image, the template that is needed to build a Docker container. This image specifies the OS that the container will use, and it can include packages and applications.
The Submitty team has create a Docker image for our class. It uses the Debian OS, and it includes the packages needed for the projects, including Python and Java. This image is hosted in the Docker Hub, a public repository for Docker images.
To get this image, execute the following command in your terminal:docker pull submittyrpi/csci4510:combined
Next, you want to create a container that uses this image. To do this, you execute the followign command, replacing with CONTAINER_NAME the name you want to give your container:docker create -t -i --name CONTAINER_NAME -w /project1 submittyrpi/csci4510:combined /bin/bash
This command creates a container that incluedes a project1 directory, a bash shell.
Next, you need to start your container by executing the following command:docker start -i -a CONTAINER_NAME
This command also attaches the containers standard input and output to your terminal so you can interact with it.
To copy files to your container, you need to first open another terminal. Then, inside this second terminal, execute the following:docker cp bin CONTAINER_NAME:project1
This command copies the contents of the bin directory on your computer to the project1 directory in your container. You can then switch back to your first terminal and you will be able to view/edit those files and/or run your programs.
You can use the above command to copy files to your container as many times as you need to. Please note: if you edit or create files in your container, the changes will not automatically be synced back to the copies of the files on your computer. You need to use different docker commands to make this happen.
When you are done with your container, you can exit it by entering the exit command. This will detatch your standard in and out from the container.
To stop the container, execute the following in your terminal:docker stop CONTAINER_NAME
You can remove the container with the following command:docker rm CONTAINER_NAME
If you remove a container, you lose all of the files stored in that container.
When you are done working with Docker, you can delete the image with the following command:docker rmi submittyrpi/csci4510:combined