Some commands are structured using new commands.Example, docker run is replaced by docker container run . We will discuss in detail when we concentrate on individual commands with later posts.
Now, let's see the earlier and still accessible commands.
To access docker cli:
#which docker --> docker cli installed location
#docker info --> running status and other system properties
#docker version --> details about both docker client and docker server
#docker run --> docker will create a container (everytime new)
docker run <image_to_create_container>
docker run -t <image> -->container created and out console attachs to its terminal session
-it --> interactive mode terminal attached, to come out type exit
-i --> keeps stdin open for the container
-t --> assigns a pseudo tty to the container.
Ex: docker run -it ubuntu
ubuntu -- default base image of ubuntu OS.
if not present in m/c, i.e., docker engine, it will download from the registry.docker registry is public by default.
To attach interactive terminal and run a initial command,like specific shell.
docker run -it <image> <entry-point>
Ex: docker run -it ubuntu /bin/bash
container naming:
to use certain name instead of randomly generated ID.
docker run --name <container_name>
To start a stopped container:(by exit command,say)
docker start id/custom_name
id is visible from tty left side like (root@id)#
docker stop -- to stop it and rm to delete it
To delete all stopped containers:
docker attach id/name --> to connect to tty
creating a daemonized container:
disconnect but still running in background.
docker run --name <name> -d <image> <entry-point> -c <shell command>
use -d instead of -it.
Fetching logs of container:
$docker logs -f <name> #live output is visible now from daemon.
To list all containers:
docker ps --running ones and -a will show all.
-q shows only container IDs.
Inspecting container processes:
docker top containeraname/id
to check container properties:
docker inspect id/name
o/p in json format.
use grep to filter o/p
commadn | grep -i ip
or format option
docker inspect --format '{{.NetworkSettings.IPAddress}}' id/name
Run a commnad on a container witout attaching it.
docker exec id/name hostname -->shows id
docker exec -d id/name ls
display live stream of container:
docker stats [id/name]
get realtime events of server
docker events
Reference: Top-10-docker-commands
Now, let's see the earlier and still accessible commands.
To access docker cli:
#which docker --> docker cli installed location
#docker info --> running status and other system properties
#docker version --> details about both docker client and docker server
#docker run --> docker will create a container (everytime new)
docker run <image_to_create_container>
docker run -t <image> -->container created and out console attachs to its terminal session
-it --> interactive mode terminal attached, to come out type exit
-i --> keeps stdin open for the container
-t --> assigns a pseudo tty to the container.
Ex: docker run -it ubuntu
ubuntu -- default base image of ubuntu OS.
if not present in m/c, i.e., docker engine, it will download from the registry.docker registry is public by default.
To attach interactive terminal and run a initial command,like specific shell.
docker run -it <image> <entry-point>
Ex: docker run -it ubuntu /bin/bash
container naming:
to use certain name instead of randomly generated ID.
docker run --name <container_name>
To start a stopped container:(by exit command,say)
docker start id/custom_name
id is visible from tty left side like (root@id)#
docker stop -- to stop it and rm to delete it
To delete all stopped containers:
docker rm $(docker ps -a -q)
docker attach id/name --> to connect to tty
creating a daemonized container:
disconnect but still running in background.
docker run --name <name> -d <image> <entry-point> -c <shell command>
use -d instead of -it.
Fetching logs of container:
$docker logs -f <name> #live output is visible now from daemon.
To list all containers:
docker ps --running ones and -a will show all.
-q shows only container IDs.
Inspecting container processes:
docker top containeraname/id
to check container properties:
docker inspect id/name
o/p in json format.
use grep to filter o/p
commadn | grep -i ip
or format option
docker inspect --format '{{.NetworkSettings.IPAddress}}' id/name
Run a commnad on a container witout attaching it.
docker exec id/name hostname -->shows id
docker exec -d id/name ls
display live stream of container:
docker stats [id/name]
get realtime events of server
docker events
Reference: Top-10-docker-commands
No comments:
Post a Comment