Tag Archives: docker

docker bash autocompletion

cd /etc/bash_completion.d/
wget https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker

For docker-compose:
curl -L https://raw.githubusercontent.com/Yelp/docker-compose/master/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

docker-compose latest version

VERSION=$(curl –silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po ‘”tag_name”: “\K.*\d’)
curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

docker detach from running container

To detach the tty without exiting the shell, use the escape sequence Ctrl+P followed by Ctrl+Q. More details here.

Additional info from this source:

docker run -t -i → can be detached with ^P^Qand reattached with docker attach
docker run -i → cannot be detached with ^P^Q; will disrupt stdin
docker run → cannot be detached with ^P^Q; can SIGKILL client; can reattach with docker attach

redirect input into dockerfile

docker build -t myimage:latest  -f- . <<EOF
FROM centos
CMD mkdir /app
RUN echo "file contents" > file.txt

Sending build context to Docker daemon  16.43kB
Step 1/4 : FROM centos
 ---> 470671670cac
Step 2/4 : CMD mkdir /app
 ---> Using cache
 ---> cf9be82aca00
Step 3/4 : WORKDIR /app
 ---> Using cache
 ---> 24baea1f7712
Step 4/4 : RUN echo "file contents" > file.txt
 ---> Using cache
 ---> 61db761dc411
Successfully built 61db761dc411
Successfully tagged myimage:latest

docker run --name ttt -ti -d --privileged=true myimage  "/sbin/init"
docker exec -it ttt cat '/app/file.txt'
file contents

centos 7 install docker

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker

● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2020-02-18 12:33:55 EET; 12s ago
Docs: https://docs.docker.com
Main PID: 1708 (dockerd)
Tasks: 8
Memory: 44.2M
CGroup: /system.slice/docker.service
└─1708 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Feb 18 12:33:53 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:53.665525062+02:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Feb 18 12:33:53 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:53.665553382+02:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 }] }" module=grpc
Feb 18 12:33:53 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:53.665569778+02:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Feb 18 12:33:54 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:54.249825464+02:00" level=info msg="Loading containers: start."
Feb 18 12:33:54 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:54.891677093+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address Daemon option --bip can be used to set...rred IP address"
Feb 18 12:33:55 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:55.220309512+02:00" level=info msg="Loading containers: done."
Feb 18 12:33:55 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:55.249438236+02:00" level=info msg="Docker daemon" commit=369ce74a3c graphdriver(s)=overlay2 version=19.03.6
Feb 18 12:33:55 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:55.249967901+02:00" level=info msg="Daemon has completed initialization"
Feb 18 12:33:55 centos7.test.local dockerd[1708]: time="2020-02-18T12:33:55.311906207+02:00" level=info msg="API listen on /var/run/docker.sock"
Feb 18 12:33:55 centos7.test.local systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

docker prestashop install

docker run -ti --name some-mysql2 --network prestashop-net -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=prestashop -e MYSQL_ROOT_HOST=% -p 3308:3306 -d mysql:5.7
docker run -ti --name presta1 --network prestashop-net -e DB_SERVER= -e PS_DEV_MODE=true -e PS_INSTALL_AUTO=1 -p 8080:80 -d prestashop/prestashop:1.7-7.0

That will run auto install on presta1:
/bin/sh /tmp/docker_run.sh
php /var/www/html/install/index_cli.php –domain= –db_server= –db_name=prestashop –db_user=root –db_password=admin –prefix=ps_ –firstname=John –lastname=Doe –password=prestashop_demo –[email protected] –language=en –country=gb –newsletter=0 –send_email=0



journalctl -u kubelet
kubelet[25843]: F0310 21:08:58.395379 25843 server.go:189] failed to load Kubelet config file /var/lib/kubelet/config.yaml, error
kubelet.service: main process exited, code=exited, status=255/n/a

kubeadm init

[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using ‘kubeadm config images pull’
[kubelet-start] Writing kubelet environment file with flags to file “/var/lib/kubelet/kubeadm-flags.env”
[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder “/etc/kubernetes/pki”
[certs] Generating “etcd/ca” certificate and key
[certs] Generating “etcd/server” certificate and key

union file systems overlay

mkdir -v lowerdir upperdir workdir overlay
sudo tree
├── lowerdir
├── overlay
├── upperdir
└── workdir

lowerdir layer (read only, base layer)
overlay layer (main view)
work layer (diff view, diff layer )

sudo mount -t overlay -o lowerdir=lowerdir,upperdir=upperdir,workdir=workdir overlay overlay

echo test > lowerdir/test

sudo tree
├── lowerdir
│   └── test
├── overlay
│   └── test
├── upperdir
└── workdir
└── work

echo 'some new data' >> overlay/test
sudo tree
├── lowerdir
│   └── test
├── overlay
│   └── test
├── upperdir
│   └── test
└── workdir
└── work

This is principe how docker is working.