Showing posts with label Container. Show all posts
Showing posts with label Container. Show all posts

Thursday, July 28, 2016

Docker : Command to See What Containers Are Running

In our previous blog posts we ran containers with the Fedora and CentOS images.  In this blog we are going to run a command to see which containers are running in our host system.  To get a list of all the containers running on our host Ubuntu system we type in the command docker ps -a command.











As you can see since we gave our containers a name, dev for Fedora and test for CentOS we see that in addition to the weird image ID number there's also the name dev and test being assign to the containers.  More human readable names don't you think?  This is the power of Docker.  In theory you can have your entire environment in one server box.  Dev/Test/Prod all containers in one host system.  That's why Docker gets so much hype.

Wednesday, July 27, 2016

Docker : Pull The Latest CentOS Image Into A Ubuntu Server

The beauty of Docker is that you can run a very lightweight image of another Linux distro on your host system.  In this post we will be pulling the latest image of CentOS into our docker container on our Ubuntu server.

Step-by-Step:

1. Open the terminal in Ubuntu, then make sure docker is running by typing service docker status, you should see something a message like the image below






2.  Type in the following command docker run --name test -it centos /bin/bash . The command tells Ubuntu to run docker with the name dev in interactive mode with an emulated terminal using the CentOS image with the bash shell.  If there's no local image docker will pull the latest image from CentOS




3.  After the command is completed you will running inside the CentOS container, you can tell by the changes in the prompt




4.  The weird number is in the prompt is the image ID of the CentOS image that we pulled.  If you type service docker status you will get an error message saying it does not recognize the command because docker is installed in the host machine not the CentOS image








5.  To get out of the CentOS container just type exit and you will get back to the host system

Tuesday, July 26, 2016

Docker : Pull The Latest Fedora Image Into A Ubuntu Server

The beauty of Docker is that you can run a very lightweight image of another Linux distro on your host system.  In this post we will be pulling the latest image of Fedora into our docker container on our Ubuntu server.

Step-by-Step:

1. Open the terminal in Ubuntu, then make sure docker is running by typing service docker status, you should see something a message like the image below






2.  Type in the following command docker run --name dev -it fedora /bin/bash . The command tells Ubuntu to run docker with the name dev in interactive mode with an emulated terminal using the Fedora image with the bash shell.  If there's no local image docker will pull the latest image from Fedora







3.  After the command is completed you will running inside the Fedora container, you can tell by the changes in the prompt


4.  The weird number is in the prompt is the image ID of the Fedora image that we pulled.  If you type service docker status you will get an error message saying it does not recognize the command because docker is installed in the host machine not the Fedora image









5.  To get out of the Fedora container just type exit and you will get back to the host system

Monday, July 25, 2016

Docker : Adding Non Root Users To The Docker Group In Ubuntu

One of the most common task you have to do as a Linux administrator is to add a new user.  Especially developers who always wants root access. Docker needs root access, however the person who is administering Docker is probably not the system administrator.  Most likely it will be the application developer. To accomplish this task you can use the useradd command in the Terminal session then add the new user to the Docker group.  Follow the steps below to add a new user to Ubuntu.

1.  Switch into the root user using sudo su - command



2. Type the following command useradd -s  /bin/bash -d /home/john -m john then press "Enter"












useradd is the command to add a new user to Ubuntu, below is an explaination of what each switch means in the command above

-s --shell SHELL - the login shell of the new account, which is the/bin/bash shell
-d --home-dir HOME_DIR - home directory of the new account, which is /home/john

3.  Type ls /home to list the content of the /home directory and you will see the john directory has been created for the user john



4.  We've created a new user name john, but he has no password, to set a password for john we can use the passwd command.  Type the following command to assign john a password passwd john  type in john's password when prompted with Enter new UNIX Password:   and confirm the password when prompted with Retype new UNIX password:



5.  Even though john has a login, we still don't know what John's full name is to assign a real name to the login john we can use the usermod -c command to assign the login name john a real name



the command above usermod -c "John Wallace" john assigns the name John Wallace to the user name john

Now we can add john to the Docker group

6.  First we need to find out if the docker group has been created, type cat /etc/group to look at the list of groups













As you can see the docker group has been created

7,  To add john to the docker group type gpasswd -a john docker







Now you will see that john is a part of the docker group


Thursday, July 21, 2016

Docker : Adding Docker Repository Key and Updating Docker To The Latest Version

In the previous post we installed Docker on our Ubuntu server.  Now we are going to add the Docker repository to our local server so that we can get the latest version of Docker.

Step-By-Step Instructions:

  1. Open the terminal command line tool and switch to root user with the sudo su command









2. Now we have to add the Docker repo key to our local machine by typing the following command
wget -qO- https://get.docker.com/gpg | apt-key add -










3. The next command is to add the Docker repository to the Ubuntu repository source list.  Type the following command into the terminal:
echo deb http://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list







4.  Now type apt-get update to get the latest updates from the Docker repository.  If you haven't ran update for a while.  This might take a while.

5.  After the update has completed type docker -v to the version number


Wednesday, July 20, 2016

Installing Docker On CentOS

Docker is the hottest infrastructure technology to hit the tech world in a long time.  The appeal of Docker is that it allows the infrastructure team to utilize the capacity of the servers to near full capacity.  Docker is a container.  A container is like a micro virtualization minus the operating system.  It only contains enough infrastructure to host an app, without the fat.  Hence the term container is used to describe it.

Here are the steps to install Docker on a CentOS Server:

1.  Open the CentOS terminal, then type the following command to switch to the super user:
     sudo su









2.  Now get the latest update for CentOS by typing yum update

3.  To install Docker type the following command in the terminal
   yum install -y docker


4.  Once the installation is complete type following command to start the docker service
     systemctl start docker.service, then type systemctl status docker.service to see the current status      of our docker container.  You should see the message that says "active (running)" in green.











Now we have Docker installed and running on CentOS.

Tuesday, July 19, 2016

Installing Docker On Ubuntu Server

Docker is the hottest infrastructure technology to hit the tech world in a long time.  The appeal of Docker is that it allows the infrastructure team to utilize the capacity of the servers to near full capacity.  Docker is a container.  A container is like a micro virtualization minus the operating system.  It only contains enough infrastructure to host an app, without the fat.  Hence the term container is used to describe it.

Here are the steps to install Docker on a Ubuntu Server:

1.  Open the Ubuntu terminal, then type the following command to switch to the super user:
     sudo su

2.  Now get the latest update for Ubuntu by typing apt-get update

3.  To install Docker type the following command in the terminal
     apt-get install -y docker.io


4.  Once the installation is complete type service docker status












Now we have Docker installed and running on Ubuntu.  It was pretty simple wasn't it?