Enable Docker command-line auto completion in bash on Centos/Ubuntu

 

Docker comes with command completion for the bash and zsh shell.
Here is the procedure to enable bash auto completion in Docker CE on Centos 7 and Ubuntu

 

Install bash-completion package

on CentOS/RedHat

# yum -y install bash-completion

on Ubuntu

apt-get install bash-completion

 

Download bash completion file into /etc/bash_completion.d

# curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh

 

Logout and login again.

When I type docker im and enter TAB then, I will get the possible parameters

# docker im<TAB>
image images import

If I type docker images then TAB, docker will list the available images.

# docker images  <TAB>
nginx:latest redis

It alo shows us the parameter of each command

 

# docker ps -<TAB>
-a -f --format -l --latest --no-trunc --quiet --size 
--all --filter --help --last -n -q -s

 

 

İsmail Yenigül

Linux & AWS Certified Cloud Expert

 

 

 

 

Advertisements
Enable Docker command-line auto completion in bash on Centos/Ubuntu

Centos 6 Letsencrypt Error: Command ‘[‘/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1

If you see the following error while running ./certbot-auto on Centos 6

Error: Command ‘[‘/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1

 

Simply run export LC_ALL=C

and then repeat your certbot-auto command.

 

Centos 6 Letsencrypt Error: Command ‘[‘/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1

LetsEncrypt ‘Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA’ Fix

when you installing a new letsencrypt ssl for a domain with certbot

# certbot –apache -d mydomain.com

I got “Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA”  error message

As mentioned in the following url, my ubuntu  cerbot package from ppa:certbot/certbot repo is outdated.

https://community.letsencrypt.org/t/solution-client-with-the-currently-selected-authenticator-does-not-support-any-combination-of-challenges-that-will-satisfy-the-ca/49983

Solution until we get a package update for certbot:
Stop apache temporarily run the following command when you finish your certification process. Start apache again.

# /etc/init.d/apache2 stop

# certbot –authenticator standalone –installer apache -d  mydomain.com

# /etc/init.d/apache2 start

If you are using nginx simply change the installer parameter apache with nginx

Alternatively you can update your certbot with certbot-auto

ismail yenigul

AWS Certified Cloud Expert

LetsEncrypt ‘Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA’ Fix

Docker installation on Centos 7/Ubuntu 16.04 in 5 min

Here is to commands to install docker and run with a non-privileged user

Centos 7

sudo su -
 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 -y
systemctl start docker
systemctl enable docker
usermod -aG docker myuser

Ubuntu 16.04-LTS

sudo su -
 apt-get update
 apt-get install apt-transport-https ca-certificates curl software-properties-common
 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 apt-get update
 apt-get install docker-ce
usermod -aG docker myuser

Notes:

  • The Docker daemon starts automatically on Ubuntu. No need to enable it manually on boot
  • Docker socket file is writable by only docker group. We issued usermod command add a user to docker group.
$ ls -al /var/run/docker.sock
srw-rw----. 1 root docker 0 Feb 3 05:33 /var/run/docker.sock

then login with myuser (if you already login, then logout and login again)

run some docker commands to test

$ docker run hello-world

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

ismail yenigul

AWS Certified Cloud Expert

 

Docker installation on Centos 7/Ubuntu 16.04 in 5 min

docker error in crontab: the input device is not a TTY

when you run a docker command via crontab like below

# /usr/bin/docker exec -it containername /path/to/command

you will get “the input device is not a TTY” error message. To fix it simply remote -t parameter

-t, –tty Allocate a pseudo-TTY

and use only -i

Also no need to mention! Always use full path for the commands in cron or use PATH variable.

ismail yenigul

 

 

docker error in crontab: the input device is not a TTY

AWS EC2 instance type change and network connectivity issue

We switched from a t2.xlarge  instance type to m4.2xlarge, we lost the network connectivity for our Ubuntu instance.

I change back to t2 instance type the instance become reachable again.

when I check /var/log/cloud-init.log, AWS m4 instance ethernet interface name changed to ens3.

Performing a dhcp discovery on ens3

but 50-cloud-init.cfg was not updated. It has old eth0 ethernet name

# cat /etc/network/interfaces.d/50-cloud-init.cfg
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init’s network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

to solve the issue,

I added the following lines into /etc/network/interfaces and stop the instance & change the instance type

auto ens3
iface ens3 inet dhcp

 

ismail yenigul

AWS Certified Solution Architect

 

 

 

 

AWS EC2 instance type change and network connectivity issue