Archive for March, 2020

Docker Basics

OS: CentOS 7
Install Docker:

# yum install docker-ce-cli docker-ce

Start Docker:

# systemctl start docker


# docker –help

You can tack on a –help on the end of any command to get help of that specific option:

# docker pull –help

Pull in an image from

# docker pull ubuntu

To list your installed images and obtain the IMAGE ID:

# docker images

To run an image:

# docker run -it -d ubuntu

To view running images:

# docker ps

To stop a running container:

# docker stop ‘CONTAINTER ID

To execute a command in a container (In this case, bash in the ubuntu image.):

# docker exec -it ‘CONTAINTER ID‘ bash

To view all container, including those that are not running:

# docker ps -a

To remove a container:

# docker rm ‘CONTAINTER ID

To remove an image:
# docker rmi ‘IMAGE ID

To stop and remove a running container:

# docker rm -f ‘CONTAINTER ID

To save changes to a container:


To remove all running containers:

# docker rm -f $(docker ps -a -q)

NOTE: INSTANCE ID can refer an image or container. The next two command will return the information in json format.
To view a container’s history:

# docker history ‘INSTANCE ID

To view information about a container:

# docker inspect ‘INSTANCE ID

If you want to upload your container to the container must have a name in the following format:

# docker commit ‘CONTAINTER ID‘ ‘dockerhubuserid’/’newimagename’

To run a container and map a host port to the container port:

# docker run -it -d -p 82:80 jgz/apache2

Then, in this case, I would access my container web server from my LAN by accessing my docker host name and the port 82. So, if my hostname is jims.domain.local, the I would browse to http://jims.domain.local:82.

A Dockerfile is how you can create a container and run some commands when you start it up:
Building a Dockerfile (YAML file):

# mkdir /usr/local/docker
# cd /usr/local/docker/
# vi Dockerfile

FROM ubuntu
RUN apt-get update
RUN apt-get -y install apache2
ADD . /var/www/html
ENV name jgz

This will build the container and execute the RUN commands and ENTRYPOINT command:

# docker build . -t new_dockerfile

Ubuntu/Mint Allow Non-Privileged User To Connect To New WiFi SSID

# cd /usr/share/polkit-1/actions/

Make a backup copy of the org.freedesktop.NetworkManager.policy file:

# cp -p org.freedesktop.NetworkManager.policy org.freedesktop.NetworkManager.policy.orig

Edit the org.freedesktop.NetworkManager.policy file:

# vi org.freedesktop.NetworkManager.policy

In the <action id=”org.freedesktop.NetworkManager.settings.modify.system”> section, look for
<allow_active>auth_admin_keep</allow_active> toward the end of the section.

Change that line to:

# shutdown -r now

Return top