Skip to content

Container Tutorial

AAbouseada edited this page Aug 27, 2021 · 2 revisions

In this tutorial I will show you how to setup a docker container environment with a persistent volume

  1. Download Docker for Windows  / Mac  / Linux

  2. Download VSCode For Windows, Mac, Linux

  3. Install Remote Development Extension Pack

  4. To download the gradle image, open a Terminal/Powershell and type:

    `docker pull gradle`
    

  5. After the image is done downloading, now its time to create the container with a persistent volume:

    You will need to change desired_path to the path you want to mount, in this example I will use /home/ed/Documents/cse3341/

    `docker create -it --entrypoint /bin/bash --name cse3341 -v desired_path:/home/gradle/ gradle -s`
    

  6. Start the container you just created:

    `docker start cse3341`
    

  7. To attach to a running In Visual Studio Code, click on the green extension on the bottom left and then select attach to a running container.

  8. To add a new working directory, go to File -> Add Folder to Workspace... and then select your path. In this example the path is /home/gradle/

Testing out the persistent volume:

Testing out python and java:

Some useful commands to know for docker:

To see a list of all containers: docker ps -a

To see a list of running containers: docker ps

To stop a running container: docker kill container_name or container_id

To start a stopped container: docker start container_name or container_id

To attach your current terminal to a container: docker attach container_name or container_id