Docker and Podman Command Generator
Everyday docker and podman commands: shell, logs, exec, run, build, compose.
About this tool
Pick what you want to do, such as open a shell in a container, follow its logs, run a command, copy files, inspect it, build or clean up images, or drive Docker Compose, and get the exact docker or podman command with every flag explained. The run builder also turns a container into a Compose file, and pasted run commands can be imported and edited.
How to use it
- Choose Docker or Podman; the commands are the same apart from the program name.
- Pick a task on the left, like Open a shell, View logs or Clean up disk space.
- Fill in the container name and options. The name you type carries over to the other tasks.
- Copy the command and read what each part does. For Run a new container you can also get a Compose file.
Questions
- How do I get a shell inside a running container?
- Run docker exec -it CONTAINER sh. Use bash instead of sh if the image has it; slim and Alpine images usually only have sh. Type exit to leave without stopping the container.
- How do I follow the logs of a container?
- docker logs -f --tail 100 CONTAINER shows the last 100 lines and keeps streaming. Add --since 10m for recent lines only, and pipe through grep -i --line-buffered error to filter as lines arrive.
- How do I turn a docker run command into docker compose?
- Paste the command into the import box and switch the result to Compose file. Ports, volumes, environment variables, restart policy, network and resource limits are carried over.
- What does -p 8080:80 mean?
- The left number is the port on your machine and the right one is the port inside the container. Prefix it with 127.0.0.1: to make the port reachable only from your own computer.
- What is the difference between a named volume and a bind mount?
- A bind mount like ./data:/data maps a folder from your machine. A named volume like pgdata:/var/lib/postgresql/data is storage managed by Docker, which survives the container and is the usual choice for databases.
- Are Docker and Podman commands the same?
- Almost: podman run accepts the same flags. The main differences are rootless defaults, so host ports below 1024 need extra setup, and SELinux systems often need :Z on bind mounts.
- Should I put passwords in -e flags?
- They end up in your shell history and in docker inspect. For anything beyond local testing, use an --env-file kept out of version control, or your platform’s secrets feature.
- How do I find a container’s IP address?
- Pick Inspect a container and choose IP address: the tool writes the docker inspect --format template for you. You rarely need the IP, though. Containers on the same user-defined network or Compose project reach each other by name, such as db:5432, and the IP can change every time a container is recreated.
- Can I copy files out of a stopped container?
- Yes. docker cp CONTAINER:/var/log/app.log ./ works whether the container is running or stopped, which makes it handy for grabbing logs or crash dumps after a failure. It copies whole folders too. Use Copy files in or out to get the command in either direction.
- What is the difference between docker stop and docker kill?
- docker stop sends SIGTERM, waits 10 seconds (change it with -t) and then sends SIGKILL. docker kill sends SIGKILL at once, with no chance to clean up. If stop always takes the full 10 seconds, your program probably ignores SIGTERM, often because a shell runs as process 1 and doesn’t pass the signal on.
docker exec vs docker run
docker run creates a new container from an image and starts it. docker exec runs a command inside a container that is already running. A common mistake is docker run -it nginx bash to “get into” a server: it starts a fresh container next to the real one, and anything you change there disappears. Without --rm, each attempt also leaves a stopped container behind that docker ps -a will show.
docker exec only works while the container runs, so it can’t help with a container that crashes on start. Read docker logs --tail 50 CONTAINER first. Then start the image with a shell instead of its normal program: docker run -it --rm --entrypoint sh IMAGE. The run builder has Entrypoint and Command fields under More options for this.
How to free disk space used by Docker
Start with docker system df, which shows how much space images, containers, local volumes and the build cache take. docker image prune removes only dangling images, the untagged leftovers of rebuilds. docker image prune -a removes every image no container uses, so you download them again next time. docker container prune deletes stopped containers, which also frees their writable layers.
Be careful with volumes: they hold database files and uploads. docker volume prune deletes volumes no container uses, and on Docker 23 and newer it removes only anonymous volumes unless you add -a. docker system prune -a --volumes clears almost everything unused in one go. Prune commands ask for confirmation unless you add -f, and nothing goes to a trash folder, so read the prompt before you confirm.
Docker restart policies: unless-stopped vs always
With --restart always, Docker restarts the container whenever it exits, and also when the Docker daemon starts, even if you stopped the container by hand before. unless-stopped behaves the same, except a container you stopped yourself stays stopped after a reboot. on-failure restarts only after a non-zero exit code. The default, no, never restarts. For long-running services, unless-stopped is usually the right choice.
In a Compose file the same setting is restart: unless-stopped. The value “no” has to be quoted, because older YAML parsers read a bare no as false, and the Compose output here quotes it for you. Podman is different: it has no always-running daemon, so containers with a restart policy come back after a reboot only if the podman-restart service is enabled, or if you run them under systemd.
Something not working, or a result looks wrong? Report a problem with this tool