Installing Docker on CentOS and Ubuntu
To begin, let’s install Docker using the following command. This will download and run a shell script that will add the Docker repository to our system and install the package.
Next, use systemctl command to start the main Docker service and check its status.
At this point we can simply execute.
to view the list of available commands or to get help.
will tell us how to list containers present on our system, whereas
will print all the options that we can use to manipulate a container.
Setting Up an Apache Container
One of the amazing things about the Docker ecosystem is that there are tens of standard containers that you can easily download and use. In the following example we will instantiate an Apache 2.4 container named tecmint-web, detached from the current terminal. We will use an image called httpd:2.4 from Docker Hub.
Our plan is to have requests made to our public IP address on port 8080 be redirected to port 80 on the container. Also, instead of serving content from the container itself, we will serve a simple web page from /home/user/website.
We do this by mapping /home/user/website/ on the /usr/local/apache2/htdocs/ on the container. Note that you will need to use sudo or log in as root to proceed, and do not omit the forward slashes at the end of each directory.
At this point our Apache container should be up and running.
Now let’s create a simple web page named docker.html inside /home/user/website directory.
Add the following sample HTML content to file.
Next, point your browser to AAA.BBB.CCC.DDD:8080/docker.html (where AAA.BBB.CCC.DDD is your host’s public IP address). You should be presented with the page we created previously.
If you wish, you can now stop the container.
and remove it:
To finish cleaning up, you may want to delete the image that was used in the container (omit this step if you’re planning on creating other Apache 2.4 containers soon).
Note that in all the above steps we never had to install the web server on our host.
Tidak ada komentar:
Posting Komentar