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
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[ Docker First Steps ]]
== Docker related info broken down in chapters ==


== Docker First Steps ==
[[ Docker First Steps ]]


=== Installation ===
[[ Building Containerized Applications ]]
<code>
apt-get install -y apt-transport-https ca-certificates surl software-properties-common
</code> <br>


If needed import the docker repo <br>
[[ Docker Networking ]]
<code>
apt-get update 
</code> <br>


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


== Useful commands ==
[[ Scaling ]]


==== Information ====
[[Category:Docker]]
<code>
docker info
</code> <br>
 
==== Check Version of client and server ====
<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>
 
== Storing your images locally ==
 
==== Create a directory for the registry ====
<code>
mkdir registry
</code> <br>
 
==== Launch a private registry ====
<code>
docker run -d -p 5000:5000 --restart-always --name registry -v $PWD/registry:/var/lig/registry registry
</code> <br>
 
==== Get Busybox ====
<code>
docker pull busybox
</code> <br>
 
==== Tag the image ====
<code>
docker tag busybox localhost:5000/phenixbox
</code> <br>
 
==== Commit to local storage ====
<code>
docker push localhost:5000/phenixbox
</code> <br>
 
==== Cleanup  ====
<code>
docker rmi -f $(docker images -a -q)
</code> <br>
 
==== Check changes ====
<code>
docker images
</code> <br>
 
==== Push to local ====
<code>
docker pull localhost:5000/phenixbox
</code> <br>
 
==== Check results ====
<code>
docker images
</code> <br>

Latest revision as of 00:13, 25 April 2020