No edit summary |
|||
Line 18: | Line 18: | ||
=== Useful commands === | === Useful commands === | ||
Information | ==== Information ==== | ||
<br> | |||
<code> | <code> | ||
docker info | docker info | ||
</code> <br> | </code> <br> | ||
Check Version of client and server <br> | ==== Check Version of client and server ==== | ||
<br> | |||
<code> | <code> | ||
docker version | docker version | ||
</code> <br> | </code> <br> | ||
Search images (usually from hub.docker.com) <br> | ==== Search images (usually from hub.docker.com) ==== | ||
<br> | |||
<code> | <code> | ||
docker search ''image'' | docker search ''image'' | ||
</code> <br> | </code> <br> | ||
Get images you want to run | ==== Get images you want to run ==== | ||
<br> | |||
<code> | <code> | ||
docker pull ''image'' | docker pull ''image'' |
Revision as of 20:11, 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 images
docker search image
Run Hello World (Shows a Hello World message on the commandline)
docker pull hello-world
docker run hello-world
Stop Hello World
docker stop hello-world
Get rid of it
docker rm hello-world
HTTPD Example
Run httpd webserver
docker pull httpd
docker run httpd
Run http and expose it to the outside world (-p container:host)
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
Or doing use method 2
docker run -d v /var/www/html:/var/www/ httpd
docker
docker
docker
llll
docker