Docker Run Command with Examples

The basic syntax for the command is

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
to run container
docker run [docker_image]
list of all containers (running and stopped) with the command:
docker ps -a
access a command prompt inside the running container:
docker container run -it [docker_image] /bin/bash
start/stop docker container:
docker start [docker_image]
map TCP port 80 in the container to port 8080 on the Docker host you would run:
docker container run -p 8080:80 [docker_image]
Mount volume from host to container:
docker run -v [/host/volume/location]:[/container/storage] [docker_image]
remove unused container images:
docker image prune -a
Stop All Docker Containers:
docker kill $(docker ps -q)
Remove All Docker Containers:
docker rm $(docker ps -a -q)

Rasika Preethiraj

A technophile at icrony since 2012, In a quest to programmatic automations for scaled organisations through the use of python, php, autoit and machine learning


Comments


Post a Comment



Trending

Latest Posts

Tags

Newsletter

Subscribe to our newsletter for good news, sent out every month.