This is an exhaustive list of commands used for docker.
To install Docker
docker ps | docker ps -a
docker images
Run a container using the image | Run a container and specify the name | Run a container with tag and ports
docker run <image> | docker run -d --name <name> <image> | docker run -p <host-port>:<container-port> <image>:<tag> <network-name> <image>
docker run -e <env-var> <image> | docker run -d -e MYSQL_ROOT_PASSWORD=<password> --name <name> --network
docker run --network=wp-mysql-network -e DB_Host=mysql-db -e DB_Password=db_pass123 -p 38080:8080 --name webapp --link mysql-db:mysql-db -d kodekloud/simple-webapp-mysql
docker exec -it <container_id_or_name> bash
docker run -d <image>
Ctrl+C / docker stop <container-id> | docker stop $(docker ps -aq)
docker rm <container-id> | docker rm $(docker ps -aq)
docker rmi <image> | docker rmi $(docker images -aq) # Stop and delete containers before deleting images
docker pull <image>
{}:{Port-published-on-the-Host}->{Port-exposed-on-container}/tcp | 0.0.0.0:3456->3456/tcp
grep -i FROM /<Path>/Dockerfile
cat Dockerfile-<image> | grep <parameter>'| cat Dockerfile-mysql | grep ENTRYPOINT | cat Dockerfile-wordpress | grep CMD
cd <desired_directory_with_Dockerfile>
docker build -t <image-name>:<tag> . # "."(dot) indicates for the current directory
docker run <image> cat /etc/*release*
docker inspect <container-name> | docker inspect <container-name> | grep -A 10 Env
docker exec -it <container-name> env
docker network ls | docker network inspect bridge
docker inspect alpine-1
docker network create --driver bridge --subnet <subnet> --gateway <gateway> <network-name>
docker run -v <data-path>:/var/lib/<data> <image> |
docker run \
--mount type=bind,source=<data-path>,target=/var/lib/<data> <image>
docker-compose up
Rocker is a A tool to run docker images with customized local support injected for things like nvidia support and user id specific files for cleaner mounting file permissions.
To install Rocker
There are a number of integrated extensions. Here are some of the highlights. You can get full details on the extensions from the main rocker --help command.
x11 -- Enable the use of X11 inside the container via the host X instance.
nvidia -- Enable NVIDIA graphics cards for rendering
cuda -- Enable NVIDIA CUDA in the container
user -- Create a user inside the container with the same settings as the host and run commands inside the container as that user.
home -- Mount the user's home directory into the container
pulse -- Mount pulse audio into the container
ssh -- Pass through ssh access to the container.
privileged -- Grants a Docker container root capabilities to all devices on the host system
rocker --nvidia --x11 osrf/ros:melodic-desktop-full gazebo
--volume /file_path_on_host_pc:/file_path_on_docker. The changes made in the docker will be reflected.
rocker --nvidia --x11 osrf/ros:humble-desktop-full --volume /home/ros_ws/my_robot_description:/home/ros_ws/my_robot_description
rocker --privileged --x11 --volume ~/Downloads/docker_ros_noetic:/urdf_output -- ros:noetic