Using Docker on Debian 9
Basic commands and techniques for working with Docker on Debian 9.
Docker is software for automating the deployment and management of applications using container-level virtualization. It lets you package an application with all its dependencies into an isolated container that can be moved to any Linux system with cgroups support.

For installation instructions, see Installing Docker on Debian 9.
Basic commands
The docker command syntax:
docker [option] [command] [arguments]
List all available subcommands:
docker
Get help for a specific subcommand:
docker docker-subcommand --help
Display general Docker information:
docker info
Working with images
By default, Docker pulls images from Docker Hub. To verify access to the registry, run the test container:
docker run hello-world
Expected output:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Search for an image:
docker search debian
The OK value in the OFFICIAL column means the image is maintained by the project's developer.
Pull an image:
docker pull debian
Run an image:
docker run <name>
List downloaded images:
docker images
Example output:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 1d622ef86b13 13 days ago 73.9MB
debian latest 3de0e2c97e5c 2 weeks ago 114MB
hello-world latest bf756fb1ae65 4 months ago 13.3kB
Running a container
To start an interactive container with shell access, use the -it flags:
docker run -it debian
The prompt will change to the container's shell:
root@e4a123443895:/#
From here you can run any commands inside the container. For example, install Node.js:
apt update
apt install nodejs
Verify the installation:
node -v
v10.19.0
All changes apply only to the current container. Type exit to leave.
Managing containers
List active containers:
docker ps
List all containers including stopped ones:
docker ps -a
Show the most recently created container:
docker ps -l
Start a stopped container:
docker start e4a123443895
Stop a running container:
docker stop tender_hugle
Remove a container:
docker rm tender_hugle
Use docker ps -a to find the container ID or name.
Saving changes to a new image
After modifying a container, you can save the changes as a new image using docker commit:
docker commit -m "What you did to the image" -a "Author Name" container_id repository/new_image_name
-m— commit message describing the changes.-a— author name.container_id— the container's ID.repository— your Docker Hub username.
For example:
docker commit -m "added Node.js" -a "test" e4a123443895 test/debian-nodejs
The new image will appear in your local image list:
docker images
Example output:
REPOSITORY TAG IMAGE ID CREATED SIZE
test/debian-nodejs latest ef3923c87c69 30 seconds ago 203MB
ubuntu latest 1d622ef86b13 13 days ago 73.9MB
debian latest 3de0e2c97e5c 2 weeks ago 114MB
hello-world latest bf756fb1ae65 4 months ago 13.3kB
Help
If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!