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
Line 19: Line 19:


==== Information ====
==== Information ====
  <br>
<code>
<code>
docker info
docker info
Line 25: Line 24:


==== Check Version of client and server ====
==== Check Version of client and server ====
<br>
<code>
<code>
docker version
docker version
Line 31: Line 29:


==== Search images (usually from hub.docker.com) ====
==== Search images (usually from hub.docker.com) ====
<br>
<code>
<code>
docker search ''image''
docker search ''image''
Line 37: Line 34:


==== Get images you want to run ====
==== Get images you want to run ====
  <br>
<code>
<code>
docker pull ''image''
docker pull ''image''
Line 43: Line 39:


==== Show the images ====  
==== Show the images ====  
<br>
<code>
<code>
docker image
docker image
</code> <br>
</code> <br>


==== Run an image in a container ====
==== Run an image in a container ====
<br>
<code>
<code>
docker run ''image''
docker run ''image''
Line 56: Line 49:


==== Stop the container ====
==== Stop the container ====
<br>
<code>
<code>
docker stop ''image''
docker stop ''image''
Line 62: Line 54:


==== Start the container ====  
==== Start the container ====  
<br>
<code>
<code>
docker stop ''image''
docker stop ''image''
Line 68: Line 59:


==== Remove the image ====  
==== Remove the image ====  
<br>
<code>
<code>
docker rm ''image''
docker rm ''image''
Line 76: Line 66:


==== Open the bash shell ====
==== Open the bash shell ====
  <br>
<code>
<code>
docker exec -it ''image'' /bin bash
docker exec -it ''image'' /bin bash
Line 84: Line 73:


==== Search Hello World Image ====  
==== Search Hello World Image ====  
<br>
<code>
<code>
docker search ''image''
docker search ''image''
Line 90: Line 78:


==== Pull Hello World ====
==== Pull Hello World ====
<br>
<code>
<code>
docker pull hello-world
docker pull hello-world
Line 96: Line 83:


==== Run hello-world ====  
==== Run hello-world ====  
<br>
<code>
<code>
docker run hello-world
docker run hello-world
Line 102: Line 88:


==== Stop Hello World ====  
==== Stop Hello World ====  
<br>
<code>
<code>
docker stop hello-world
docker stop hello-world
Line 108: Line 93:


==== Get rid of Hello World ====
==== Get rid of Hello World ====
<br>
<code>
<code>
docker rm hello-world
docker rm hello-world
Line 116: Line 100:


==== Run httpd webserver ====  
==== Run httpd webserver ====  
<br>
<code>
<code>
docker pull httpd
docker pull httpd
Line 123: Line 106:


==== Run http and expose it to the outside world ====
==== Run http and expose it to the outside world ====
<br>
<code>
<code>
docker run -p 80:80 --name web01 -d httpd
docker run -p 80:80 --name web01 -d httpd
Line 129: Line 111:


==== Show running containers ====  
==== Show running containers ====  
<br>
<code>  
<code>  
docker ps
docker ps
Line 135: Line 116:


==== Get stuff from the webserver ====
==== Get stuff from the webserver ====
<br>
<code>
<code>
curl localhost
curl localhost
Line 141: Line 121:


==== Stop the container ====  
==== Stop the container ====  
<br>
<code>
<code>
docker stop web01
docker stop web01
Line 147: Line 126:


==== Remove the container ====  
==== Remove the container ====  
<br>
<code>
<code>
docker rm web01
docker rm web01
Line 157: Line 135:


==== Expose a folder to the container method 1 ====  
==== Expose a folder to the container method 1 ====  
<br>
<code>
<code>
docker volume create data
docker volume create data

Revision as of 21:22, 24 April 2020

Docker First Steps

Installation

apt-get install -y apt-transport-https ca-certificates surl software-properties-common

If needed import the docker repo
apt-get update

Install Docker
apt-get install docker-ce

Useful commands

Information

docker info

Check Version of client and server

docker version

Search images (usually from hub.docker.com)

docker search image

Get images you want to run

docker pull image

Show the images

docker image

Run an image in a container

docker run image

Stop the container

docker stop image

Start the container

docker stop image

Remove the image

docker rm image

Interaction with the Container

Open the bash shell

docker exec -it image /bin bash

Hello world example

Search Hello World Image

docker search image

Pull Hello World

docker pull hello-world <c/ode>

Run hello-world

docker run hello-world

Stop Hello World

docker stop hello-world

Get rid of Hello World

docker rm hello-world

HTTPD Example

Run httpd webserver

docker pull httpd docker run httpd

Run http and expose it to the outside world

docker run -p 80:80 --name web01 -d httpd

Show running containers

docker ps

Get stuff from the webserver

curl localhost

Stop the container

docker stop web01

Remove the container

docker rm web01

Docker Adding Persistance Storage

This provides the local data to run in the container, for instance the data for the website

Expose a folder to the container method 1

docker volume create data

docker run -v /var/www/html:/var/www/ httpd

Expose a folder to the container method 2


docker run -d v /var/www/html:/var/www/ httpd


docker


docker


docker


docker

Comments