Difference between revisions of "Docker basics"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Docker|Docker</yambe:breadcrumb> =Docker basics= ==Run a docker image== To run a docker image use #:<pre> #:: docker run hello-world #:</pre> Docker firs...")
 
m
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Docker|Docker</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 7.x]] > [[CentOS 7.x virtualization|Virtualization]] > [[CentOS 7.x Docker|Docker]] > [[Docker basics]]
=Docker basics=


==Run a docker image==
==Run a docker image==
To run a docker image use
To run a docker image use
#:<pre>
<pre>
#::    docker run hello-world
    docker run hello-world
#:</pre>
</pre>
Docker first searches for image locally.  If it is not found then it will download the image from docker hub and run it.
Docker first searches for image locally.  If it is not found then it will download the image from docker hub and run it.


Line 12: Line 11:
==See local docker images in cache==
==See local docker images in cache==
To see local docker images in cache use:
To see local docker images in cache use:
#:<pre>
<pre>
#::    docker images
    docker images
#:</pre>
</pre>


Docker basics are learned from https://docs.docker.com/linux/started/
==Download public docker images==
Public docker images are available at https://hub.docker.com/  They can be downloaded using:
<pre>
docker pull centos
</pre>
Then the same image can be used using:
<pre>
docker run -it centos bash
</pre>


Most images have documentation explaining their purpose and how to use them.


Docker basics are learned from https://docs.docker.com/linux/started/


==Listing currently running docker containers==
To list currently running docker containers use:
<pre>
docker ps
</pre>
Read "man docker" for more information on docker command
Instead if you want to list stopped/killed containers use:
<pre>
docker ps --all
</pre>
==Deleting a docker container==
To delete a docker container, first list the containers using:
<pre>
docker ps --all
</pre>
Then delete the desired container using:
<pre>
docker rm &lt;container-name&gt;
</pre>
To delete all docker containers on the system use:
<pre>
docker ps --all | wc -l
docker rm $(docker ps --all | tail -&lt;count&gt; | cut -b1-12)
</pre>
where count is one less than number reported in wc -l to exclude the top title row.








<yambe:breadcrumb>Docker|Docker</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 7.x]] > [[CentOS 7.x virtualization|Virtualization]] > [[CentOS 7.x Docker|Docker]] > [[Docker basics]]

Latest revision as of 08:55, 25 August 2022

Home > CentOS > CentOS 7.x > Virtualization > Docker > Docker basics

Run a docker image

To run a docker image use

    docker run hello-world

Docker first searches for image locally. If it is not found then it will download the image from docker hub and run it.


See local docker images in cache

To see local docker images in cache use:

    docker images

Docker basics are learned from https://docs.docker.com/linux/started/


Download public docker images

Public docker images are available at https://hub.docker.com/ They can be downloaded using:

docker pull centos

Then the same image can be used using:

docker run -it centos bash

Most images have documentation explaining their purpose and how to use them.


Listing currently running docker containers

To list currently running docker containers use:

docker ps

Read "man docker" for more information on docker command

Instead if you want to list stopped/killed containers use:

docker ps --all


Deleting a docker container

To delete a docker container, first list the containers using:

docker ps --all

Then delete the desired container using:

docker rm <container-name>

To delete all docker containers on the system use:

docker ps --all | wc -l
docker rm $(docker ps --all | tail -<count> | cut -b1-12)

where count is one less than number reported in wc -l to exclude the top title row.



Home > CentOS > CentOS 7.x > Virtualization > Docker > Docker basics