SM1:
Open-source operating systems |
ASIX/DAW/DAM-1 |
Task A11: Deployment or
installation of application using Docker containers |
20-1-25 |
or alternatively:
This command downloads the official image, version 3.0, of Photon OS, which is an open source minimal Linux.
This command downloads the latest version of an official image, which is called httpd in the DockerHub repository, with the software required to start an Apache web server when a new docker container is created using this image.
In this example, you can see that two images called photon and httpd have been downloaded to your system.c) Creating and starting a docker container: Basic options
The command creates a new container with the official image of Photon OS version 3. The new container will be called photon03. No particular application is asked to be run when the docker container is started. The docker container is running always in the background and will be stopped using docker stop (section 2.e). The docker container is ready to run any application installed using docker exec(section 2.g). The full Container ID is shown by the host machine operating system. Options -i and -t are added in case we wanted to run a container shell.
The command creates a container with the latest version of the Apache HTTP Server official image. The new container will be called apache2. Port 80 of container is exposed to port 8080 in the host machine. Container runs always in the background. No particular application is asked to be run when the docker container is started. Options -i and -t are added in case we want to run a container's shell (command interpreter).
Container ID --> Container IDentifier. A unique number that identifies the docker container.
Name --> A unique name that identifies the docker container
Status --> Up means that the docker container is running on your system. Exited means that the docker container has been stopped.
Ports --> What internal port/ports of your docker container is/are exposed to port/ports of your host machine.
Image --> Image used to create the docker container
In this example, you can see how to stop a docker container using its Container ID.
In this example, you can see how to stop a docker container using its Name.
In this example, you can see how to start a docker container using its Name or Container ID.
In this example, you can see how to gain access to the docker container executing the program bash installed in the container. Option -it is required because we want an interactive session and we want to work with a terminal and command interpreter. Also, we want to remain in the command interpreter and run some commands until the command exit is run.
We have run a command (cat /usr/local/apache2/htdocs/index.html) in the docker container usign the Container ID. This command shows the contents of index.html in the container. We do not remain, we just run a single command in the container.
We have run a command (ls -ls /usr) in the docker container photon03. This command shows the contents of /usr in the container. We do not remain, we just run a single command in the container.
In this example:
a) Docker container photon03 is stopped using its Container Name
b) Docker container apache2 is stopped using its Container ID
c) Docker container photon3 is already stopped so, running docker stop is not required.
d) Docker containers photon03 and photon3 are removed using their Container Names
e) Docker container apache2 is removed using its Container ID
In this example:
a) Docker image photon:3.0 is removed
b) Docker image httpd:latest is removed
c) We can see the list of images installed on the host machine before and after running the commands to remove images.
d) We can see the disk space usage of the host machine before and after running the commands to remove images. Check changes in the Used and Available space.
The Docker daemon dockerd manages
Docker objects such as images, containers, networks, and
volumes. A daemon can also communicate with other daemons to
manage Docker services.