Basic Docker
1. Introduction
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. It is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.

2. Prerequisites
There is some requirements that we need to know before getting to know more about docker
- Know some of Linux command line
- Basic knowledge about virtual server (vagrant ..)
3. Architecture Design

- Container : is a virtualization run-time environment where users can isolate applications from the underlying system
- Image : it is the source of application which is already build for installing or running
- Registry : it is remote repository for storing docker image (nexus, dockerhub, aws ecr (elastic container registry)…)
4. Basic Command
Below is some of basic important command docker
- List Containers
docker ps
# your can add available [OPTIONS] below
docker ps -aq
# only shows IDs
[OPTIONS] : https://docs.docker.com/engine/reference/commandline/ps/
— all
# or -a Show all containers (default shows just running)
— filter
# or -f Filter output based on conditions provided
— format
# Pretty -print containers using a Go template
Example:

- Stop Container
docker stop CONTAINER_ID
# copy container id from docker ps
docker stop $(docker ps -aq)
# stop all Running containers
Example:

- Remove Container
docker rm CONTAINER_ID
# Delete Specific container
docker rm $(docker ps -aq)
# Remove all container
Example:

- List Image
docker images
# List all available images in your machine.
docker image ls -aq
# list image ids only
Example:


- Build Image
docker image build -t IMAGE_NAME(repo):BUILD_NUMBER(tag) .
# build image based on docker file in Current directory (.)
- Run Image

Example:
docker run — name laravel-app -p 8000:8000 kimly/laravelapp:latest
- Run Command inside Running Container or enter your container
docker container exec -it container_id or name bash or sh
Example :
- docker container exec -it 1aa5b15c26ff bash
- docker container exec -it laravel-app sh
5. Installation
Ubuntu Server
Install using the repository
1. Update the apt package index and install packages to allow apt
to use a repository over HTTPS:
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
2. Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88
3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.
$ sudo add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable”
$ sudo apt install docker.io
root@testserver:~# docker — version
Docker version 19.03.6, build 369ce74a3c
More detail: Link : https://docs.docker.com/engine/install/ubuntu/
Mac Os
follow this link : https://docs.docker.com/docker-for-mac/install/
Finally, thank you for your time reading this article, I hope it can give you some new knowledge.
#cambodiandevops#devopskh#docker#container#sharingiscaring#sharewhatyouhaved