Posted in Home, Life in Europe

Work-life balance of Software Engineer in Germany

The issues around finding the balance between family life, private life and work are gaining increased attention in political and business circles in Europe and Germany.

A key issue for many workers is flexible working time in order to have a work-life balance. Negotiating a work/life balance can help enable parents (both men and women) to reconcile their work with their family lives and women in particular to participate in the labour market. Finding the right work-life balance can allow workers to take leave from work so that they can participate in education or training or take up an interest, hobby or leisure pursuit. This may mean that employees can reorganise their working lives and hours around shorter days, weeks, months or years.

German families tend to be small with only one or two children. The men are still quite often considered to be the head of the household, even though both the wife and husband work.

At the turn of the century few employees in Germany were given holidays. In 1902, the metal and brewing industries gave three days annual leave to their workers. It was not until 1974 that the old Federal Republic introduced the statutory minimum holiday of 18 working days which has now risen to a minimum of 24 days. Today most collective wage agreements provide for holidays of six weeks or more and most employers give  holiday pay.

National holidays

Germany has quite generous holidays in comparison to other European countries. There are more public holidays in Germany than in any other European country. On these days, banks and most shops are closed, including supermarkets. However, many restaurants remain open. Public transportation and other services are also available. Many shops and businesses are also closed on Carnival Rose Monday (Cologne and Rhine region), Christmas Eve and New Year’s Eve although these are not official holidays.

Overview of legal holidays:

New Year                
Epiphany                   
Good Friday              
Easter Monday               
Labour Day               
Ascension                  
Whit Monday             
Corpus Christi                       
Assumption Day        
Day of German Unity            
Reformation Day       
All Saints’ Day                       
Penance Day              
Christmas                  
St. Stephen’s Day
01.01
06.01   (celebrated in BW, BY, ST)
around March/April
around March/April
01.05
May
May
May/June (celebrated in  BW, BY, HE, NW, RP, SL)
15.08   (celebrated in  BY, SL)
03.10
31.10   (celebrated in  BB, MV, SN, ST, TH)
01.11   (celebrated in BW, BY, NW, RP, SL
21.11   (celebrated in SN)
25.12
26.12

(Those States where the public holiday applies are shown in brackets; if nothing is indicated the holiday applies to all of Germany.)

Working hours

Opening hours

In Germany, businesses and shops are not legally allowed to stay open as long as they please and there are strict regulations concerning opening and closing hours. The German federal law “Ladenschlussgesetz” (Shop Closing Law) together with individual regulations in different States controls opening hours. Thus supermarkets for example close at 22.00 at the latest and open before 9 a.m. or 10 a.m. On Sundays almost everything is closed with the exception of bakeries and petrol stations.

 Working times

The German Working Time Regulations (“Arbeitszeitgesetz”) regulate working hours on a legal basis. They are based on the European regulation 93/104/EG. In addition, most industries have collective agreements that regulate working hours and holidays. However, it can be said, that a working week of more than 48 hours on average during a  6 month period must not be exceeded. Furthermore, Sundays and national holidays are non-working days.

Working culture

Germans see themselves as modern, liberal and cultured, and working practices are formal and professional. The following outlines the working practices that you should be familiar with before investing in Germany:

  • Though long-term relationships are considered very important, friendships are usually not developed too quickly. It may take some time before personal names are used between non-familial parties.
  • German business culture has a well-defined and strictly observed hierarchy, with clear responsibilities and distinctions between roles and departments.
  • Professional rank and status in Germany is generally based on an individual’s achievement and expertise in a given field. Academic titles and backgrounds are important, conveying an individual’s expertise and thorough knowledge of their particular area of work.
  • An important aspect is Germany’s work ethic. Employees define themselves as part of the corporation they are working for and quickly identify themselves with its product and/ or services.
  • Rank is very important in business. Never set up a meeting for a lower ranked company employee to meet with a higher ranked person.
  • Notwithstanding what has been said previously, today over half of all university graduates are women. Female students are well represented in the professions; they lead in some fields such as medicine and law. The new availability of qualified female graduates is likely to bring great changes in the German workplace of the future.
  • Pay and power inequalities are still present however. Male employees tend to receive higher wages than their female counterparts. Jobs considered as being “women’s work” typically pay less than those deemed “men’s work”.
  • In more traditional companies, it is still generally true that everything is run by committees, things are discussed in great length and risk taking is not as common as in other countries.
  • There is one philosophy for almost everybody in German business: if someone says he is going to do something, he will do it. The same is expected of others as well. Never make a promise that you cannot keep or offer something that you cannot deliver. Germans dislike and do not trust unreliable people.
  • There is no legislated or administratively determined minimum wage. Collective bargaining agreements set minimum pay rates and are enforceable by law for an estimated 80 to 90 per cent of all wage and salary earners
  • Federal regulations limit the working week to a maximum of 48 hours, but collective bargaining agreements may supersede these. Contracts that directly or indirectly affect 80% of the working population regulate the number of hours of work per week.
  • The average working week is around 40 hours; rest periods for lunch are accepted practice. Provisions for overtime, holidays, and weekend pay vary depending upon the applicable collective bargaining agreement.
  • An extensive set of laws and regulations govern occupational health and safety. A comprehensive system of worker insurance enforces safety requirements in the workplace.

It is important that these issues are examined and understood before setting up a company and employing a workforce in Germany. These issues differ all over Europe but legal guidelines are set by the European Commission.

Health insurance

Germany’s health care system provides its residents with nearly universal access to comprehensive high-quality medical care and a choice of physicians. Over 90% of the population receives health care through the country’s statutory health care insurance programme. Membership of this programme is compulsory for all those earning less than a periodically revised income ceiling. Nearly all of the remainder of the population receives health care via private for-profit insurance companies. Everyone uses the same health care facilities.

Posted in Live*

US Election 2020 – What Asian American Think.[Live 11.06.2020]

Combination picture of Democratic U.S. presidential nominee Joe Biden and US President Donald Trump speaking about the early results of the 2020 election on 4 November 2020
image captionThe result of Tuesday’s election hangs in the balance

The information I show in this post only represent for my idea. A Vietnamese engineer in Europe.

Before we discuss further, let’s update some information about the Election in American first:

Democratic candidate Joe Biden has pulled ahead of Donald Trump in Pennsylvania, a key state in the US presidential race, voting data shows.

If Mr Biden takes the state, he would secure his victory in the election. The state has 20 Electoral College votes.

According to the most recent data, Mr Biden is leading by more than 5,500 votes, with 98% counted.

Earlier, Mr Biden edged ahead of his Republican rival in Georgia, another key battleground state.

He is leading there with more than 1,000 votes, with 99% of the ballots counted.

No news organisation has yet projected it as a Biden win. Georgia is a traditionally Republican state and has not been won by a Democrat since 1992.

If Mr Biden wins Pennsylvania, the state where he was born, he would have 273 votes in the electoral college – enough to clinch the victory.

Pennsylvania has always been a major political battleground. The state voted Democrat in six consecutive races before it swung to Mr Trump in 2016.

Paths to victory

How about Asian-American, what they think and who they want to be the 46th president of US. And this is what I found from internet.

Indian-Americans voted for Biden, Vietnamese-Americans supported Trump.

According to post-voting polls, about 64% of Asian American voters support Biden, while 30% of them vote for Trump.

These figures are similar to 2016, but lower than the numbers Obama collected in 2012.

Asian Americans were the fastest growing minority of voters eligible to vote. Although this group’s voter rate is still less than 5%, it may still be the deciding factor in fluctuating states.

According to the Asian-American Voter Survey, the Republican Party has gradually received support from this group in recent years, but nearly two-fifths of Asian-American voters have yet to register as a member of either two parties, meaning they may be “undecided voters”.

Asian-American voters are far from other blocs. They come from many different backgrounds, including country of origin, culture, religion and generation. According to the survey above, Indian Americans tend to vote for Biden the most, while Vietnamese Americans tend to favor Trump.

Although President Trump has been widely criticized for calling Covid-19 “the Chinese virus”, he has received enthusiastic support from a number of Chinese Americans.

Chenren Shao, a 35-year-old Chinese-American Republican voter in Maryland, said he was not offended by the term, as the virus started to emerge from China.

In addition, similar to the Cuban Americans who supported Trump, many Chinese immigrants who criticized Beijing have also praised Trump for claiming he stood up against communism.

Historically, both of these major parties have not had adequate access to Asian-American voters, resulting in a low turnout rate in this group. But in the near future, this electoral block will become large so that politicians must pay more attention.

Posted in Life in Europe

Living in Europe

In this post I will tell you about life of a Asian Developer in Europe. It actually really hard but some time it is, like in the below picture , when you see the guy grow up in home town with sea and temperature always higher than 25, now he need to go home under the weather -5 degree.

This is my bicycle, in Germany where I live, you don’t need a bicycle because you can rent one.

This is the first car I was drive to in Germany, to get a driving license here you need from 2000 to 3000 euros. But It’s still small compare to the money you need to spent every month to your car, have a car in Germany is expensive.

Posted in Home

Live*

This is a page to share my thoughts and feelings about new events, happening live today or in the near future, all I share is my personal thoughts, looking forward to discussing with everyone.

VIDEO] Live Stream Best Practices (1/2) | Believe

Đây là chuyên mục cập nhật thường ngày, nơi mình đưa ra những bài viết về những vấn đề nổi cộm hiện nay, tất nhiên là dưới góc nhìn của một lập trình viên kinh nghiệm đang làm việc tại 1 trong những công ty vận tải lớn nhất thế giới:

Nội dung chia sẻ bao gồm:

Lập trình

Khoa học máy tính

Thông tin kinh tế, chính trị xã hội

Hoặc các chủ đề khác nếu nhiều bạn thích nói về nó thì mình sẽ viết bài trên này hoặc là làm vlog youtube để nói về vấn đề đó , các bạn theo dõi kênh của mình tại đây nhé:

How to build Robot Project in Frankfurt University Germany – YouTube

Posted in Docker

Docker & Kubernetes- Helm chart repository

Creating a Helm chart repository

In this post, we’ll learn how to create and work with Helm chart repositories.

A chart repository is an HTTP server that houses an index.yaml file and optionally some packaged charts. Because a chart repository can be any HTTP server that can serve YAML and tar files and can answer GET requests, we have a plethora of options when it comes down to hosting our own chart repository. For example, we can use a Google Cloud Storage (GCS) bucket, Amazon S3 bucket, GitHub Pages, or even create our own web server.

Once the charts are ready and we need to share them, the easiest way to do so is by uploading them to a chart repository. However, Helm does not come with a chart repository while Helm can serve the local repository via “helm serve”.

Github Pages

We can create charts repository using GitHub Pages. It allows us to serve static web pages.

All we need is to host a single index.yaml file along with a bunch of .tgz files.

Create a new Github repositoryCreate-a-new-Github-Repo.png

Though it’s empty repo, let’s just clone it for now:

$ git clone https://github.com/Einsteinish/dummy-helm-charts.git    

Create a helm chart

We need to have the Helm CLI installed and initialized:

$ helm version
Client: &version.Version{SemVer:"v2.16.10", GitCommit:"bceca24a91639f045f22ab0f41e47589a932cf5e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.10", GitCommit:"bceca24a91639f045f22ab0f41e47589a932cf5e", GitTreeState:"clean"}

$ helm3 version
version.BuildInfo{Version:"v3.3.1", GitCommit:"249e5215cde0c3fa72e27eb7a30e8d55c9696144", GitTreeState:"dirty", GoVersion:"go1.15"}    

We’re going to use the directory ./sources/ for the sources of our charts. We need to create charts and copy them into the ./sources/:

$ cd dummy-helm-charts/
$ mkdir sources  

$ tree
.
└── dummy-helm-charts
    ├── README.md
    └── sources
    
$ helm create sources/dummy-chart
Creating sources/dummy-chart

$ tree
.
├── README.md
└── sources
    └── dummy-chart
        ├── Chart.yaml
        ├── charts
        ├── templates
        │   ├── NOTES.txt
        │   ├── _helpers.tpl
        │   ├── deployment.yaml
        │   ├── ingress.yaml
        │   ├── service.yaml
        │   ├── serviceaccount.yaml
        │   └── tests
        │       └── test-connection.yaml
        └── values.yaml
        
$ helm lint sources/*
==> Linting sources/dummy-chart
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, no failures

Create the Helm chart package

$ helm package sources/*
Successfully packaged chart and saved it to: 
/Users/kihyuckhong/Documents/Minikube/Helm/DUMMY/dummy-helm-charts/dummy-chart-0.1.0.tgz

Create the repository index

A chart repository is an HTTP server that houses an index.yaml file.

The index file contains information about each chart and provides the download URL, for example, https://example.com/charts/alpine-0.1.2.tgz for that chart.

The index file is a yaml file called index.yaml. It contains some metadata about the package, including the contents of a chart’s Chart.yaml file. A valid chart repository must have an index file. The helm repo index command will generate an index file based on a given local directory that contains packaged charts.

$ helm repo index --url https://einsteinish.github.io/helm-chart/ . 

$ tree
.
├── README.md
├── dummy-chart-0.1.0.tgz
├── index.yaml
└── sources
    └── dummy-chart
        ├── Chart.yaml
        ├── charts
        ├── templates
        │   ├── NOTES.txt
        │   ├── _helpers.tpl
        │   ├── deployment.yaml
        │   ├── ingress.yaml
        │   ├── service.yaml
        │   ├── serviceaccount.yaml
        │   └── tests
        │       └── test-connection.yaml
        └── values.yaml


$ cat index.yaml
apiVersion: v1
entries:
  dummy-chart:
  - apiVersion: v1
    appVersion: "1.0"
    created: "2020-10-22T13:11:36.940863-07:00"
    description: A Helm chart for Kubernetes
    digest: c8d82f24fc29d40693a608a1fd8db1c2596a8325ecae62529502a1cbae8677a2
    name: dummy-chart
    urls:
    - https://einsteinish.github.io/helm-chart/dummy-chart-0.1.0.tgz
    version: 0.1.0
generated: "2020-10-22T13:11:36.935738-07:00"

Pushing to Github repository

$ git add .

$ git commit -m "initial commit"
[main 4006e22] initial commit
 12 files changed, 322 insertions(+)
 create mode 100644 dummy-chart-0.1.0.tgz
 create mode 100644 index.yaml
 create mode 100644 sources/dummy-chart/.helmignore
 create mode 100644 sources/dummy-chart/Chart.yaml
 create mode 100644 sources/dummy-chart/templates/NOTES.txt
 create mode 100644 sources/dummy-chart/templates/_helpers.tpl
 create mode 100644 sources/dummy-chart/templates/deployment.yaml
 create mode 100644 sources/dummy-chart/templates/ingress.yaml
 create mode 100644 sources/dummy-chart/templates/service.yaml
 create mode 100644 sources/dummy-chart/templates/serviceaccount.yaml
 create mode 100644 sources/dummy-chart/templates/tests/test-connection.yaml
 create mode 100644 sources/dummy-chart/values.yaml

$ git push origin main
...
To https://github.com/Einsteinish/dummy-helm-charts.git
   9d23dff..4006e22  main -> main    

Setting up Github Pages as a helm chart repository

From “settings” of git repository, scroll down to Github Pages section and configure it as follow:Github-Pages-save.png

Click “Save”:Github-Pages-saved.png

Helm client configuration

To use the charts on the repository, we need to configure their own Helm client using helm repo command:

$ helm repo add dummy https://einsteinish.github.io/dummy-helm-charts
"dummy" has been added to your repositories
~/Documents/Minikube/Helm/DUMMY/dummy-helm-charts $ helm repo list
NAME  	URL                                             
stable	https://kubernetes-charts.storage.googleapis.com
local 	http://127.0.0.1:8879/charts                    
dummy 	https://einsteinish.github.io/dummy-helm-charts

$ helm search dummy
NAME             	CHART VERSION	APP VERSION	DESCRIPTION                
dummy/dummy-chart	0.1.0        	1.0        	A Helm chart for Kubernetes
local/dummy-chart	0.1.0        	1.0        	A Helm chart for Kubernetes

Chart repository updates

Whenever we want to add a new chart to the Helm chart repository, we should regenerate the index.yaml file. The helm repo index command will rebuild the index.yaml file including only the charts that it finds locally. Note that we can use the –merge flag to incrementally add new charts to an existing index.yaml:

$ helm repo index --url https://einsteinish.github.io/dummy-helm-charts/ --merge index
Posted in Docker

More about Docker run command

Docker run command

The basic syntax for the Docker run command looks like this:

k@laptop:~$ docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container

We’re going to use very tiny linux distribution called busybox which has several stripped-down Unix tools in a single executable file and runs in a variety of POSIX environments such as Linux, Android, FreeBSD, etc. It’s going to execute a shell command in a newly created container, then it will put us on a shell prompt:

k@laptop:~$ docker run -it busybox sh
/ # echo 'bogotobogo'
bogotobogo
/ # exit
k@laptop:~$

The docker ps shows us containers:

k@laptop:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

But right now, we don’t have any containers running. If we use docker ps -a, it will display all containers even if it’s not running:

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
4d673944ec59        busybox:latest      "sh"                13 minutes ago      Exited (0) 12 minutes ago                       trusting_mccarthy   

When we execute run command, it will create a new container and execute a command within that container. The container will remain until it is explicitly deleted. We can restart the container:

k@laptop:~$ docker restart 4d673944ec59
4d673944ec59   

We can attach to that container. The usage looks like this:

docker attach [OPTIONS] CONTAINER

Let’s attach to the container. It will put us back on the shell where we were before:

k@laptop:~$ docker attach 4d673944ec59

/ # ls
bin      etc      lib      linuxrc  mnt      proc     run      sys      usr
dev      home     lib64    media    opt      root     sbin     tmp      var
/ # exit

The docker attach command allows us to attach to a running container using the container’s ID or name, either to view its ongoing output or to control it interactively.

Now, we know that a container can be restarted, attached, or even be killed!

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
4d673944ec59        busybox:latest      "sh"                21 minutes ago      Exited (0) About a minute ago                       trusting_mccarthy  

But the one thing we can’t do changing the command that’s been executed. So, once we have created a container and it has a command associated with it, that command will always get run when we restart the container. We can restart and attached to it because it has shell command. But if we’re running something else, like an echo command:

k@laptop:~$ docker run -it busybox echo 'bogotobogo'
bogotobogo

Now, we’ve created another container which does echo:

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES
849975841b4e        busybox:latest      "echo bogotobogo"   About a minute ago   Exited (0) About a minute ago                       elegant_goldstine   
4d673944ec59        busybox:latest      "sh"                29 minutes ago       Exited (0) 9 minutes ago                            trusting_mccarthy

It executed “echo bogotobogo”, and then exited. But it still hanging around. Even if we restart it:

k@laptop:~$ docker restart 849975841b4e
849975841b4e

It run in background and we don’t see any output. All it did “echo bogotobogo” again. I can remove this container:

k@laptop:~$ docker rm 849975841b4e
849975841b4e

Now it’s been removed from our list of containers:

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
4d673944ec59        busybox:latest      "sh"                35 minutes ago      Exited (0) 14 minutes ago                       trusting_mccarthy   

We want this one to be removed as well:

k@laptop:~$ docker rm 4d673944ec59
4d673944ec59
k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
k@laptop:~$ 

docker run -it

Let’s look at the -it in docker run -it.

k@laptop:~$ docker run --help

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

  -i, --interactive=false    Keep STDIN open even if not attached

  -t, --tty=false            Allocate a pseudo-TTY
...

If we run with t:

k@laptop:~$ docker run -i busybox sh

ls
bin
dev
etc
home
lib
lib64
linuxrc
media
mnt
opt
proc
root
run
sbin
sys
tmp
usr
var

cd home

cd /home

ls
default
ftp

exit
k@laptop:~$

It is interactive mode, and we can do whatever we want: “ls”, “cd /home” etc, however, it does not give us console, tty.

If we issue the docker run with just t:

k@laptop:~$ docker run -t busybox sh
/ #

We get a terminal we can work on. But we can’t do anything because it cannot get any input from us. We can execute anything since it’s not getting what we’re passing in.

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                        PORTS               NAMES
3bcaa1d57ac0        busybox:latest      "sh"                15 seconds ago       Up 14 seconds                                     dreamy_yonath           
ac53c2a81ebe        busybox:latest      "sh"                About a minute ago   Exited (127) 55 seconds ago                       condescending_galileo   
497be20f5d7e        busybox:latest      "sh"                3 minutes ago        Exited (-1) 2 minutes ago                         nostalgic_wilson  

Docker run –rm

We need to kill the container run with only “t”:

      
k@laptop:~$ docker kill 3bcaa1d57ac0
3bcaa1d57ac0

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES
3bcaa1d57ac0        busybox:latest      "sh"                3 minutes ago       Exited (-1) 2 minutes ago                        dreamy_yonath           
ac53c2a81ebe        busybox:latest      "sh"                3 minutes ago       Exited (127) 3 minutes ago                       condescending_galileo   
497be20f5d7e        busybox:latest      "sh"                6 minutes ago       Exited (-1) 4 minutes ago                        nostalgic_wilson        

Then, we want to remove all containers:

 
k@laptop:~$ docker rm $(docker ps -aq)
3bcaa1d57ac0
ac53c2a81ebe
497be20f5d7e

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
k@laptop:~$ 

The argument q in docker ps -aq gives us id of all containers.

The next thing to do here is that we don’t want remove the containers every time we execute a shell command:

 
k@laptop:~$ docker run -it --rm busybox sh
/ # echo Hello
Hello
/ # exit

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
k@laptop:~$ 

Notice that we don’t have any container. By passing in --rm, the container is automatically deleted once the container exited.

 
k@laptop:~$ docker run -it --rm busybox echo "I will not staying around forever"
I will not staying around forever
k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
k@laptop:~$ 

Docker rmi – deleting local images

To remove all images from our local machine:

k@laptop:~$ docker rmi $(docker images -q)

Saving container – docker commit

As we work with a container and continue to perform actions on it (install software, configure files etc.), to have it keep its state, we need to commit. Committing makes sure that everything continues from where they left next time.

Exit docker container:

root@f510d7bb05af:/# exit
exit

Then, we can save the image:

# Usage: sudo docker commit [container ID] [image name]
$ sudo docker commit f510d7bb05af my_image

Running CentOS on Ubuntu 14.04

As an exercise, we now want to run CentOS on Ubuntu 14.04.

Before running it, check if we have have any Docker container including running ones:

k@laptop:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

OK. There is no running Docker. How about any exited containers:

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Nothings there!

Let’s search Docker registry:

k@laptop:~$ docker search centos
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                          The official build of CentOS.                   1223      [OK]       
ansible/centos7-ansible         Ansible on Centos7                              50                   [OK]
jdeathe/centos-ssh-apache-php   CentOS-6 6.6 x86_64 / Apache / PHP / PHP m...   11                   [OK]
blalor/centos                   Bare-bones base CentOS 6.5 image                9                    [OK]
...

We can download the image using docker pull command. The command find the image by name on Docker Hub and download it from Docker Hub to a local image cache.

k@laptop:~$ docker pull centos
latest: Pulling from centos
c852f6d61e65: Pull complete 
7322fbe74aa5: Pull complete 
f1b10cd84249: Already exists 
Digest: sha256:90305c9112250c7e3746425477f1c4ef112b03b4abe78c612e092037bfecc3b7
Status: Downloaded newer image for centos:latest

Note that when the image is successfully downloaded, we see a 12 character hash: Download complete which is the short form of the image ID. These short image IDs are the first 12 characters of the full image ID – which can be found using docker inspect or docker images –no-trunc=true:

k@laptop:~$ docker inspect centos:latest
[
{
    "Id": "7322fbe74aa5632b33a400959867c8ac4290e9c5112877a7754be70cfe5d66e9",
    "Parent": "c852f6d61e65cddf1e8af1f6cd7db78543bfb83cdcd36845541cf6d9dfef20a0",
    "Comment": "",
    "Created": "2015-06-18T17:28:29.311137972Z",
    "Container": "d6b8ab6e62ce7fa9516cff5e3c83db40287dc61b5c229e0c190749b1fbaeba3f",
    "ContainerConfig": {
        "Hostname": "545cb0ebeb25",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": null,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": null,
        "Cmd": [
            "/bin/sh",
            "-c",
            "#(nop) CMD [\"/bin/bash\"]"
        ],
        "Image": "c852f6d61e65cddf1e8af1f6cd7db78543bfb83cdcd36845541cf6d9dfef20a0",
        "Volumes": null,
        "VolumeDriver": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "MacAddress": "",
        "OnBuild": null,
        "Labels": {}
    },
    "DockerVersion": "1.6.2",
    "Author": "The CentOS Project \u003ccloud-ops@centos.org\u003e - ami_creator",
    "Config": {
        "Hostname": "545cb0ebeb25",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": null,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": null,
        "Cmd": [
            "/bin/bash"
        ],
        "Image": "c852f6d61e65cddf1e8af1f6cd7db78543bfb83cdcd36845541cf6d9dfef20a0",
        "Volumes": null,
        "VolumeDriver": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "MacAddress": "",
        "OnBuild": null,
        "Labels": {}
    },
    "Architecture": "amd64",
    "Os": "linux",
    "Size": 0,
    "VirtualSize": 172237380
}
]

Or:

k@laptop:~$ docker images --no-trunc=true
REPOSITORY          TAG                 IMAGE ID                                                           CREATED             VIRTUAL SIZE
centos              latest              7322fbe74aa5632b33a400959867c8ac4290e9c5112877a7754be70cfe5d66e9   8 weeks ago         172.2 MB

k@laptop:~$ docker images --no-trunc=false

Or:

k@laptop:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              latest              7322fbe74aa5        8 weeks ago         172.2 MB

Let’s run Docker with the image:

k@laptop:~$ docker run -it centos:latest /bin/bash
[root@33b55acb4814 /]# 

Now, we are on CentOS. Let’s make a file, and then just exit:

[root@33b55acb4814 /]# cd /home

[root@33b55acb4814 home]# touch bogo.txt

[root@33b55acb4814 home]# ls
bogo.txt

[root@33b55acb4814 home]# exit
exit

k@laptop:~$

Check if there is any running container:

k@laptop:~$ docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Nothings’ there. The docker ps command shows only the running containers. So, if we want to see all containers, we need to add -a flag to the command:

k@laptop:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
33b55acb4814        centos:latest       "/bin/bash"         2 minutes ago       Exited (0) 51 seconds ago                       grave_jang          

We do not have any Docker process that’s actively running. But we can restart the one that we’ve just exited from.

$ docker restart 33b55acb4814
33b55acb4814

k@laptop:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
33b55acb4814        centos:latest       "/bin/bash"         4 minutes ago       Up 4 seconds                            grave_jang          

Note that the container is now running, and it actually executed the /bin/bash command.

We can go back to where we left by executing docker attach ContainerID command:

k@laptop:~$ docker attach 33b55acb4814

[root@33b55acb4814 /]# 

Now, we’re back. To make sure, we can check if there is the file we created:

[root@33b55acb4814 /]# cd /home
[root@33b55acb4814 home]# ls
bogo.txt