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 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 images

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

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


Configuring images and create new ones from it

Commit the image

docker commit image

Tag it yours

docker tag user/image:tag

Launc the Container

Tag it yours

docker run image

== Make an image publicly available

Login to DockerHub

docker login

Send it!

docker push user/image

Cleanup

docker rmi -f httpd

PhenixOps Wehserver Example

Stop httpd

docker stop httpd

Commit the changes

docker commit httpd phenixweb

Tag the image

docker tag httpd phenixops/phenixweb

Check the result

docker images

Run it!

docker run phenixweb

docker push phenixops/phenicweb

Cleanup

docker rmi -f httpd

Save Downloaded Docker Images

Get the image

docker pull nginx

Save the image

docker save nginx > nginx.tar

Use the backed up image

docker load < nginx.tar

Storing your images locally

Create a directory for the registry

mkdir registry

Launch a private registry

docker run -d -p 5000:5000 --restart-always --name registry -v $PWD/registry:/var/lig/registry registry

Get Busybox

docker pull busybox

Tag the image

docker tag busybox localhost:5000/phenixbox

Commit to local storage

docker push localhost:5000/phenixbox

Cleanup

docker rmi -f $(docker images -a -q)

Check changes

docker images

Push to local

docker pull localhost:5000/phenixbox

Check results

docker images