diff --git a/CloudComputing_Lab/modules/ROOT/nav.adoc b/CloudComputing_Lab/modules/ROOT/nav.adoc index 5ef2ffe..5c13e2c 100644 --- a/CloudComputing_Lab/modules/ROOT/nav.adoc +++ b/CloudComputing_Lab/modules/ROOT/nav.adoc @@ -7,4 +7,5 @@ * xref:f.adoc[Docker Swarm] * xref:docker-build.adoc[DigitalSkills-docker_build] * xref:docker-compose.adoc[DigitalSkills-deploy_service] +* xref:admin.adoc[DigitalSkills-ServiceAdmin] * xref:tech-list.adoc[Getting_started] diff --git a/CloudComputing_Lab/modules/ROOT/pages/admin.adoc b/CloudComputing_Lab/modules/ROOT/pages/admin.adoc new file mode 100644 index 0000000..228e3e9 --- /dev/null +++ b/CloudComputing_Lab/modules/ROOT/pages/admin.adoc @@ -0,0 +1,213 @@ += Services Admin + +== Displaying Docker Images + +To see the list of Docker images on the system, you can issue the following command. + +.docker images +[source,sh] +---- +docker images +---- + +This command is used to display all the images currently installed on the system. + + +**Output:** + +- TAG − This is used to logically tag images. +- Image ID − This is used to uniquely identify the image. +- Created − The number of days since the image was created. +- Virtual Size − The size of the image. + +== Removing Docker Images + +The Docker images on the system can be removed via the docker rmi command. + +.docker images +[source,sh] +---- +docker rmi + +This command is used to remove Docker images. +Syntax + +docker rmi ImageID +---- + + +== Containers + +Containers are instances of Docker images that can be run using the Docker run command. The basic purpose of Docker is to run containers. + + +=== Running a Container + +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 +---- + + +=== Listing of Containers + +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 +---- + +=== Display the running processes of a container + + +With this command, you can see the top processes within a container. +Syntax + +.docker top +[source,sh] +---- +docker top ContainerID + +Options + + ContainerID − This is the Container ID for which you want to see the top processes. +---- + +=== Stop a running container + +This command is used to stop a running container. + +.docker stop +[source,sh] +---- +docker stop ContainerID + +Options + + ContainerID − This is the Container ID which needs to be stopped. +---- + +=== Attach a running container + + +This command is used to attach to a running container. + +.docker +[source,sh] +---- +docker attach ContainerID + +Options + + ContainerID − This is the Container ID to which you need to attach. +---- + + +=== Delete container + +This command is used to delete a container. + +.docker rm +[source,sh] +---- +docker rm ContainerID + +Options + + ContainerID − This is the Container ID which needs to be removed. +---- + +=== Container Logging + +Logging is also available at the container level. + +.docker log +[source,sh] +---- +Docker logs containerID + +Parameters + + containerID − This is the ID of the container for which you need to see the logs. +---- + +== Volumes + +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 +---- + + +== repositories + +You might have the need to have your own private repositories. You may not want to host the repositories on Docker Hub. For this, there is a repository container itself from Docker. Let’s see how we can download and use the container for registry. + + +=== Create + +.docker registry +[source,sh] +---- +docker run –d –p 5000:5000 –-name registry registry:2 + +The following points need to be noted about the above command: + + Registry is the container managed by Docker which can be used to host private repositories. + + The port number exposed by the container is 5000. Hence with the –p command, we are mapping the same port number to the 5000 port number on our localhost. + + We are just tagging the registry container as “2”, to differentiate it on the Docker host. + + The –d option is used to run the container in detached mode. This is so that the container can run in the background +---- + + +== Docker Hub + +Docker Hub is a registry service on the cloud that allows you to download Docker images that are built by other communities. You can also upload your own Docker built images to Docker hub. + +To run apache, you need to run the following command: + +.run docker image from Docker Hub +[source,sh] +---- +docker run -p 8080:80 apache + +Note the following points about the above command − + + + Here, apache is the name of the image we want to download from Docker hub and install on our Ubuntu machine. + + -p is used to map the port number of the internal Docker image to our main Ubuntu server so that we can access the container accordingly. +---- + + +=== Push + +use the Docker push command to push the image to our private repository. + +.docker registry +[source,sh] +---- +docker push localhost:5000/myimage +---- + +=== Pull + +use the following Docker pull command to pull image from our private repository. + +.docker registry +[source,sh] +---- +docker pull localhost:5000/myimage +---- +