Install and use Docker at Ubuntu 14.04

  • 2020-05-30 21:26:11
  • OfStack

Docker is open source software that encapsulates both an Linux application and its dependencies (such as configuration files) into a single container. However, unlike virtual machines, Docker USES a sandbox mechanism where the Docker container does not run the operating system, but shares the operating system on the host. Next I will install and use Docker on Ubuntu 14.04.

Docker enables more applications to run on the same server -- it does so by providing an additional layer of abstraction and operating system-level virtual automation. Docker was developed in the Go language and released under the Apache 2.0 license.

1. Requirements for Docker

To install Docker on Ubuntu 14.04 x64, you need to make sure that the version of Ubuntu is 64-bit and that the kernel version is larger than version 3.10.

1. Check the kernel version of Ubuntu

# uname -r 

2. Update the system to ensure the validity of the software package list

# apt-get update

3. If the version of Ubuntu is not satisfied, you need to upgrade Ubuntu

# apt-get -y upgrade

2. Install Docker

Once all the requirements are met, you can start installing Docker. Docker initially only supported Ubuntu, but later there were releases of CentOS and other RedHat related packages. Setup is simple, execute the command:

# apt-get -y install

3. Create links

Create soft links

 # ln -sf /usr/bin/ /usr/local/bin/docker
 # sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/

4. Check the Docker service

To verify the status of the Docker service, execute the following command to ensure that the Docker service is started.

# service status start/running, process 14394

To run Docker as a daemon, execute the following command :(note that the Docker service must be turned off first)

# docker -d &

5. Docker self-starting service

Install Docker as a self-starting service and let it run automatically when the server is started. Execute the following commands:

# update-rc.d defaults

6. Use of Docker

Here's how to use Docker. To see the commands available for Docker, run the docker command on the terminal, which prints a list of all available commands and a description of how to use them.

# docker

7. Docker container download

Next, we will use the docker command with the pull option to pull an image and download an Docker image from the Docker registered server's software store.

The commands used are as follows:

# docker pull ubuntu

This command will take some time to execute.

8. Run the Docker container

You can now see that setting up the Ubuntu container under Bash Shell is as simple as running 1 line of command.

-i option: allow input and output to be done on the standard console

-t option: assign 1 tty

# apt-get update

Therefore, in the output prompt, you can see the standard Ubuntu container in use.

You can now use Bash Shell in the Docker container of Ubuntu. If you want to stop/disconnect, you can use the key combination Ctrl-p + Ctrl-q and return to the previous window.

9. Docker group

Create an docker user group, avoid using root users, and have users in the docker user group have the same permissions as root.

# apt-get update

You can now log out of the current user and log in using docker.

10. Docker test

To view the output, execute the following command:

# apt-get update

The output in the snapshot shows that the docker user is working properly.

101. Docker is available in containers

The available containers for Docker can be found through the search command, and the community has provided a number of available containers. To find available Docker containers, use the following command to search CentOS's Docker container.

# docker search centos

102. The conclusion

This article is an introduction to Docker, and there are many challenges to go further.

Related articles: