Anonymous
×
Create a new article
Write your page title here:
We currently have 27 articles on PhenixOps. Type your article name above or click on one of the titles below and start writing!



PhenixOps
27Articles

Docker: Difference between revisions

No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Docker First Steps ==
== Docker related info broken down in chapters ==


=== Installation ===
[[ Docker First Steps ]]
<code>
apt-get install -y apt-transport-https ca-certificates surl software-properties-common
</code> <br>


If needed import the docker repo <br>
[[ Building Containerized Applications ]]
<code>
apt-get update 
</code> <br>


Install Docker <br>
[[ Docker Networking ]]
<code>
apt-get install docker-ce
</code> <br>


=== Useful commands ===
[[ Docker Compose ]]


==== Information ====
[[ Scaling ]]
<code>
docker info
</code> <br>


==== Check Version of client and server ====
[[Category:Docker]]
<code>
docker version
</code> <br>
 
==== Search images (usually from hub.docker.com) ====
<code>
docker search ''image''
</code> <br>
 
==== Get images you want to run ====
<code>
docker pull ''image''
</code> <br>
 
==== Show the images ====
<code>
docker image
</code> <br>
 
==== Run an image in a container ====
<code>
docker run ''image''
</code> <br>
 
==== Stop the container ====
<code>
docker stop ''image''
</code> <br>
 
==== Start the container ====
<code>
docker stop ''image''
</code> <br>
 
==== Remove the image ====
<code>
docker rm ''image''
</code> <br>
 
== Interaction with the Container ==
 
==== Open the bash shell ====
<code>
docker exec -it ''image'' /bin bash
</code> <br>
 
== Hello world example ==
 
==== Search Hello World Image ====
<code>
docker search ''image''
</code> <br>
 
==== Pull Hello World ====
<code>
docker pull hello-world
</code> <br>
 
==== Run hello-world ====
<code>
docker run hello-world
</code> <br>
 
==== Stop Hello World ====
<code>
docker stop hello-world
</code> <br>
 
==== Get rid of Hello World ====
<code>
docker rm hello-world
</code> <br>
 
== HTTPD Example ==
 
==== Run httpd webserver ====
<code>
docker pull httpd
docker run httpd
</code> <br>
 
==== Run http and expose it to the outside world ====
<code>
docker run -p 80:80 --name web01 -d httpd
</code> <br>
 
==== Show running containers ====
<code>
docker ps
</code> <br>
 
==== Get stuff from the webserver ====
<code>
curl localhost
</code> <br>
 
==== Stop the container ====
<code>
docker stop web01
</code> <br>
 
==== Remove the container ====
<code>
docker rm web01
</code> <br>
 
== Docker Adding Persistance Storage ==
 
This provides the local data to run in the container, for instance the data for the website <br>
 
==== Expose a folder to the container method 1 ====
<code>
docker volume create data
</code> <br>
 
<code>
docker run -v /var/www/html:/var/www/ ''httpd''
</code> <br>
==== Expose a folder to the container method 2 ====
<br>
 
== Configuring images and create new ones from it ==
==== Commit the image ====
<code>
docker commit ''image''
</code> <br>
 
==== Tag it yours ====
<code>
docker tag ''user/image:tag''
</code> <br>
 
Launc the Container
==== Tag it yours ====
<code>
docker run ''image''
</code> <br>
 
== Make an image publicly available
 
==== Login to DockerHub ====
<code>
docker login
</code> <br>
 
==== Send it! ====
<code>
docker push ''user/image''
</code> <br>
 
==== Cleanup ====
<code>
docker rmi -f httpd
</code> <br>
 
== PhenixOps Wehserver Example ==
 
==== Stop httpd ====
<code>
docker stop httpd
</code> <br>
 
==== Commit the changes ====
<code>
docker commit httpd phenixweb
</code> <br>
 
==== Tag the image ====
<code>
docker tag httpd phenixops/phenixweb
</code> <br>
 
==== Check the result ====
<code>
docker images
</code> <br>
 
==== Run it! ====
<code>
docker run phenixweb
</code> <br>
 
<code>
docker push phenixops/phenicweb
</code> <br>
 
==== Cleanup ====
<code>
docker rmi -f httpd
</code> <br>
 
== Save Downloaded Docker Images ==
 
==== Get the image ====
<code>
docker pull nginx
</code> <br>
 
==== Save the image ====
<code>
docker save nginx > nginx.tar
</code> <br>
 
==== Use the backed up image ====
<code>
docker load < nginx.tar
</code> <br>

Latest revision as of 23:13, 24 April 2020