Docker3


Docker containers

Install Docker CE(Community Edition)

$ sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2$ sudo yum-config-manager \
 
$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

$ sudo yum install docker-ce docker-ce-cli containerd.io

$ sudo systemctl start docker
$ sudo systemctl enable docker (start at boot)
$ sudo docker run hello-world (pulls image from docker libaray and indicates docker is working okay)

Above command displays the below

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash
$ sudo systemctl disable docker (stop running at boot)

Uninstall Docker

sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

Some Docker Commands

docker ps
docker version

Docker Pull Image

docker pull debian:latest
CTRL -C during pull cancels the pull
docker images (displays the images)
docker container run debian (will exit since no input has been provideed)
but below command will work
docker container run -it debian /bin/bash

docker container rm c55680af670c (will remove particular docker container)
#stop all containers:
docker stop $(docker ps -a -q)

#stop all containers by force
docker kill $(docker ps -q)

#remove all containers
docker rm $(docker ps -a -q)

#remove all docker images
docker rmi $(docker images -q)

#purge the rest
docker system prune --all --force --volumes

get a ubuntu version 16

``` sudo apt-get install docker.io

sudo docker sudo docker pull ghost

sudo docker run -d -p 80:2368 ghost

sudo docker ps

sudo apt install docker-compose

docker-compose up -d docker-compose down

version: ‘2’ services: web: restart: always image: ghost ports: - 80:2368 volumes: - /home/ubuntu/ghost:/var/lib/ghost/content environment: NODE_ENV: production url: http://192.168.56.101

Image Title
Image Title

These writings represent my own personal views alone.
Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.