docker run -d to start a container, docker ps -a to list containers, docker logs -f <name> to read output, docker exec -it <name> sh to open a shell, docker stop and docker rm to stop and remove, and docker system df to see disk use. Each table below gives the command, what it does and an example.
Before you start
- Run the commands as a user in the
dockergroup, or putsudoin front. - You can use a container’s name (for example
web) or the first few characters of its ID wherever a command needs<name>. - An image is the read-only template. A container is a running (or stopped) copy of an image. A volume is storage that survives when you replace the container.
How to run a container
Container commands
Example output of
docker ps:
How to read container logs
How to open a shell inside a container
bash instead of sh if the image has it. Type exit to leave; the container keeps running. To run a single command without a shell:
Image commands
How to update a container to a new image
A container never changes its image. To update, pull the new image and create a new container with the same options:Volume and network commands
Containers on the same user-defined network reach each other by container name.
Disk space and clean-up
Example output of
docker system df:
Frequently asked questions
What is the difference between docker stop and docker kill?
docker stop asks the main process to shut down and waits, by default 10 seconds, before forcing it. docker kill ends it at once, which can corrupt data that is being written.
Why does my container exit straight away?
The main process ended or crashed. Rundocker ps -a to see the exit code and docker logs <name> to see the error.
How do I copy a file into or out of a container?
Usedocker cp, for example docker cp web:/etc/nginx/nginx.conf ./nginx.conf or docker cp ./index.html web:/usr/share/nginx/html/.
How do I see which ports a container publishes?
Rundocker port web. It prints lines such as 80/tcp -> 127.0.0.1:8080.
Related guides
VPS and dedicated server guides
Every guide in this section.
Install Docker
Docker Engine from the official repository.
Docker Compose tutorial
Define containers in one file.
Clean up Docker disk space
What each prune command deletes.
Install Portainer
The same tasks in a web UI.
Checked against the official Docker CLI reference on 4 November 2026; commands tested on Ubuntu 24.04 LTS with Docker Engine 29.9.2. Output can differ slightly between Docker versions.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026