-
Start gui capabilities for docker containers (host os terminal):
xhost +local:docker &> /dev/null
-
Build docker image:
docker build -t <image_name> .
- If you want to push to docker hub use this format: (repo_name is like the image_name)
docker build -t <dockerhub_username>/<repo_name>:<tag_name> .
- If you want to push to docker hub use this format: (repo_name is like the image_name)
-
Create a container from an image:
docker run -it --name <container_name> <image_name>
-
If you want gui support and you have a Nvidia graphics card use these commands instead
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"
-
for intel integrated graphics use the following:
DOCKER_COMMON_ARGS="--env="DISPLAY" --env="QT_X11_NO_MITSHM=1" -v "/tmp/.X11-unix:/tmp/.X11-unix:rw"
-
Run the following to create the container:
docker run -it --net=host --privileged $DOCKER_COMMON_ARGS --name <name_of_container> <image_name>
-
If you want to pass a folder into the container add the following to the docker run command after the --net=host: (paths need to be absolute paths)
-v <path_to_folder_on_host>:<path_to_folder_in_container>
-
-
Open an additional terminal in the container:
docker exec -it <container_name> bash
-
Start container:
docker start <container_name>
-
Stop container:
docker stop <container_name>
-
See running containers:
docker ps
-
See all containers on computer:
docker container ls -a
-
See all images on computer:
docker image ls -a
-
Delete container:
docker rm <container_name or container_ID>
-
Delete Image:
docker rmi <image_name or image_ID>
-
Push image to docker hub:(make sure you made a repo on docker hub, that you named the image corretly and you signed into docker on your computer)
docker push <dockerhub_username>/<repo_name>:<tag_name>