This Repository is a guide to all the Docker CLI commands you need to use in case any of these situations arise
- Create Container β¨
- Start Container π
- Stop Running π΄
- Container Management πΌ
- Logs π
- DOCKERFILE π³
> docker container run <image name>
NOTE: Replace <image name>
with required image name ignoring <>
> docker container create <image name>
NOTE: Replace <image name>
with required image name ignoring <>
> docker container start <container id>
NOTE: Replace <container id>
with target container id ignoring <>
> docker container start -a <container id>
NOTE: Replace <container id>
with target container id ignoring <>
> docker container run -it <container_id> sh
NOTE: Replace <container_id>
with target container id ignoring <>
> docker container run -p <to_port:from_port> <image_name>
NOTE: Replace <image_name>
with target image name and replace to_port
with the port you want to access from your machine and replace from_port
with the port in which the container uses
Ignore <>
> docker container stop <container id>
NOTE: Replace <container id>
with target container id ignoring <>
> docker container kill <container id>
NOTE: Replace <container id>
with target container id ignoring <>
> docker container ls
NOTE: Add parameter -a
to list all containers ever created
> docker system prune
> docker system prune --all
> docker container rm <continer_id>
NOTE: Replace <container_id>
with target container id ignoring <>
This might fail if the container is currently running. In that case view force delete command below
> docker container rm -f <container_id>
NOTE: Replace <container_id>
with target container id ignoring <>
> docker container logs <container id>
NOTE: Replace <container id>
with target container id ignoring <>
FROM <image>
NOTE: Replace <image>
with base image
MAINTAINER <name>
NOTE: Replace <name>
with the name you want to set for the author field
RUN <command>
NOTE: Replace <command>
with the command you want to execute on the containers shell
Click here to visit the repository containing language and framework specific templates for docker and docker compose
Gowtham Karthikeyan |