Welcome to ROSMASTER M1 repository
2.Docker basic commands
Docker basic commands
1. Not using sudo commands
Normally, Docker commands require prefixing with sudo, as shown below:
xxxxxxxxxxsudo docker versionHowever, after adding the docker group, you no longer need to prefix commands with sudo. To add the docker group (run the command on the host running Docker):
xxxxxxxxxxsudo groupadd docker # Add the docker groupsudo gpasswd -a $USER docker # Add the current user to the docker group. $USER is automatically resolved to the currently logged-in user.newgrp docker # Update the docker groupAfter adding the above commands, test the command using the [docker images] command. If no errors are reported, you can now use the command without sudo. If the following error is reported:
xxxxxxxxxxpi@ubuntu:~$ docker imagesWARNING: Error loading config file: /home/pi/.docker/config.json: open /home/pi/.docker/config.json: permission deniedThen execute the following command on the host machine to resolve the issue:
xxxxxxxxxxsudo chown "$USER":"$USER" /home/"$USER"/.docker -Rsudo chmod g+rwx "/home/$USER/.docker" -R2. Basic Docker Commands
1. Downloading the Image
⚠️If you cannot pull the image, you will need to use a secure internet connection.
xxxxxxxxxxdocker pull
2. List images
xxxxxxxxxxdocker images
Parameter explanation:
REPOSITORY: The repository of the image
TAG: The image tag IMAGE
ID: The image ID CREATED
TED: The time the image was created
SIZE: The size of the image
3. List currently running Docker images
xxxxxxxxxxdocker ps # List running containersdocker ps -a #List all running containers
If it is, it means to list all the docker images that have been run

Up indicates a running container, and Exited indicates a closed Docker container.
4. Exit a container using the exit command

5. Restart a closed Docker container
xxxxxxxxxxdocker start (container id or container name) # Start a containerdocker restart (container id or container name) # Restart a containerdocker stop (container id or container name) # Stop the containerdocker kill (container id or container name) # Forcefully stop the container
6. Deleting a container
xxxxxxxxxxdocker rm container id # Delete a specific containerdocker rm -f $(docker ps -a -q) # Delete all containersdocker ps -a -q | xargs docker rm # Delete all containers