To simplify the container process add do the following to ~/.bashrc, allow for docker to publish a window and make a bash variable with most of the needed arguments for the container.
-
Gives docker permission to publish gui windows.
echo 'xhost +local:docker &> /dev/null' >> ~/.bashrc
-
Container arguments for graphics
- Nvidia Graphics Cards:
echo 'DOCKER_COMMON_ARGS="--gpus all --env=NVIDIA_VISIBLE_DEVICES=all --env=NVIDIA_DRIVER_CAPABILITIES=all --env=DISPLAY --env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw"' >> ~/.bashrc
- Intel Integrated Graphics:
echo 'DOCKER_COMMON_ARGS="--env=DISPLAY --env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw"' >> ~/.bashrc
- Nvidia Graphics Cards:
-
Create a docker container:
docker run -it --net=host --privileged $DOCKER_COMMON_ARGS --name <name_of_container> <docker_image_name>
- If you want to have a shared folder between your host computer and the container use the following instead:
docker run -it --net=host -v <path_to_folder_on_host>:<path_to_folder_in_container> --privileged $DOCKER_COMMON_ARGS --name <name_of_container> <docker_image_name>
- Both paths need to be absolute. For the container /root/ is the same as doing ~/.
- See README.md for the updated list of docker images
- <name_of_container> can be anything thing you would like as long as it is unique from any other container name.
- If you want to have a shared folder between your host computer and the container use the following instead:
-
To connect an aditional terminal to the container run:
sudo docker exec -it <name_of_container> bash
- Open a vs code window
- Select "Docker" from the left hand side of the vs code window.
- Right click on the container and select "start" if it is not started
- Right click on a container that is started and select "Attach Visual Studio Code"
- The new window that opens will be attached to the container, meaning any terminals that you open from that vs code window will already be in the container.