|
|
@ -4,7 +4,6 @@ |
|
|
|
|
|
|
|
To see the list of Docker images on the system, you can issue the following command. |
|
|
|
|
|
|
|
.docker images |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker images |
|
|
@ -24,7 +23,6 @@ This command is used to display all the images currently installed on the system |
|
|
|
|
|
|
|
The Docker images on the system can be removed via the docker rmi command. |
|
|
|
|
|
|
|
.docker images |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker rmi |
|
|
@ -45,7 +43,6 @@ Containers are instances of Docker images that can be run using the Docker run c |
|
|
|
|
|
|
|
Running of containers is managed with the Docker run command. To run a container in an interactive mode, first launch the Docker container. |
|
|
|
|
|
|
|
.run docker image |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker run –it myimage /bin/bash |
|
|
@ -56,7 +53,6 @@ docker run –it myimage /bin/bash |
|
|
|
|
|
|
|
One can list all of the containers on the machine via the docker ps command. This command is used to return the currently running containers. |
|
|
|
|
|
|
|
.run docker image |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker ps |
|
|
@ -68,7 +64,6 @@ docker ps |
|
|
|
With this command, you can see the top processes within a container. |
|
|
|
Syntax |
|
|
|
|
|
|
|
.docker top |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker top ContainerID |
|
|
@ -82,7 +77,6 @@ Options |
|
|
|
|
|
|
|
This command is used to stop a running container. |
|
|
|
|
|
|
|
.docker stop |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker stop ContainerID |
|
|
@ -97,7 +91,6 @@ Options |
|
|
|
|
|
|
|
This command is used to attach to a running container. |
|
|
|
|
|
|
|
.docker |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker attach ContainerID |
|
|
@ -112,7 +105,6 @@ Options |
|
|
|
|
|
|
|
This command is used to delete a container. |
|
|
|
|
|
|
|
.docker rm |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker rm ContainerID |
|
|
@ -126,7 +118,6 @@ Options |
|
|
|
|
|
|
|
Logging is also available at the container level. |
|
|
|
|
|
|
|
.docker log |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
Docker logs containerID |
|
|
@ -140,7 +131,6 @@ Parameters |
|
|
|
|
|
|
|
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. |
|
|
|
|
|
|
|
.docker volumes |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker run -d --name mycontainer -v /var/www/html:/var/html nginx:latest |
|
|
@ -154,7 +144,6 @@ You might have the need to have your own private repositories. You may not want |
|
|
|
|
|
|
|
=== Create |
|
|
|
|
|
|
|
.docker registry |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker run –d –p 5000:5000 –-name registry registry:2 |
|
|
@ -177,7 +166,6 @@ Docker Hub is a registry service on the cloud that allows you to download Docker |
|
|
|
|
|
|
|
To run apache, you need to run the following command: |
|
|
|
|
|
|
|
.run docker image from Docker Hub |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker run -p 8080:80 apache |
|
|
@ -195,7 +183,6 @@ Note the following points about the above command − |
|
|
|
|
|
|
|
use the Docker push command to push the image to our private repository. |
|
|
|
|
|
|
|
.docker registry |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker push localhost:5000/myimage |
|
|
@ -205,7 +192,6 @@ docker push localhost:5000/myimage |
|
|
|
|
|
|
|
use the following Docker pull command to pull image from our private repository. |
|
|
|
|
|
|
|
.docker registry |
|
|
|
[source,sh] |
|
|
|
---- |
|
|
|
docker pull localhost:5000/myimage |
|
|
|