×
Community Blog Take You to Easily Play with Docker Container Technologies

Take You to Easily Play with Docker Container Technologies

This tutorial will help you easily deep understand of Docker Container from several aspects like creating cluster, applying docker commands, managing resource and etc.

Docker Container Cleanup Tutorial

This tutorial gives you practical experience in cleaning up Docker containers on Alibaba Cloud.

You need only about a week's experience with Docker to be able to understand most of this tutorial.

You need more experience as Linux administrator, since grep, awk and xargs is also used.

grep, awk and xargs are very powerful tools to use at the shell command line. It is worthwhile spending a day reading and executing tutorials on these tools. This tutorial focus on Docker; it will only give ten line descriptions where grep, awk and xargs are used. ( It only explains the one percent of grep, awk and xargs functionality we need to understand in the context of using it in docker cleanups. )

Preparation

To follow this tutorial you need an Alibaba Cloud Elastic Compute Service (ECS) server with Docker already installed. If you are not sure how, you can refer to this tutorial.

In order to learn about cleaning up containers we need some containers to clean up.

First we need some images from https://hub.docker.com/

For the purposes of this tutorial it does not matter at all what is inside those images. You need zero experience of Nginx, Redis and Alpine to understand this full tutorial completely.

Redis is an open source, in-memory data structure store, used as a database and data cache. Most programming languages can use it to make the programs faster via near-instant access to data in memory.

NGINX is a free, open-source, high-performance HTTP server: competing directly with more well-known Apache web server.

Alpine Linux is a 5MB Linux distribution, very popular with docker users.

Alpine Linux is used as a base image for docker applications. It provides a small Linux environment for running apps.

Enter the following at your shell prompt to get these 4 images downloaded onto your computer.

The docker pull command downloads Docker images from a registry. A docker registry contains a collection of Docker images.

By default, the docker pull command pulls / downloads docker images from Docker Hub: https://hub.docker.com/

Docker images are used to create running containers. Docker images contain all the software needed to run a specific application. For example, the nginx:mainline-alpine image you downloaded contains all the software needed to run Nginx in a container.

In docker pull nginx:mainline-alpine the nginx:mainline-alpine is the name of the image we want to pull / download. The image name is nginx.

The mainline-alpine is a tag. Tags are used to differentiate different versions of the same image, for example: there could be nginx:centos, nginx:ubuntu, nginx:debian8 and nginx: debian9 images at the Docker Hub repository. We use tags to specify exactly which image to download.

Related Blogs

Creating a Docker Container Cluster with Container Service

In this tutorial, we'll show you how to create a Docker container cluster using Alibaba Cloud's Container Service.

This is a prerequisite step towards running Alibaba Cloud's Container Service for managing Docker Swarm environments.

In the past, developers had to install, run, and monitor systems on physical machines in server rooms. Now, containerization with virtual management tools, such as Docker Swarm and Kubernetes, allows developers to manage and monitor production and development environments made up of Docker application containers built directly into the Alibaba Cloud Container Service.

What Is Alibaba Cloud's Container Service?

Alibaba Cloud's Container Service is a scalable, high-performance, container management service that allows you to orchestrate and manage containerized application lifecycles with either Docker Swarm or Kubernetes.

Alibaba Cloud's Container Service offers multiple application release methods, including continuous integration, and also supports a microservices architecture. By simplifying the UI setup of a container cluster, which integrates with Alibaba Cloud's virtualization, storage, network, and security services, Alibaba Cloud's Container Service is the perfect cloud environment for running, managing, and monitoring containerized application environments.

What Is Docker Swarm?

Docker is an open source, virtualization management tool that allows you to develop, deploy, manage, and monitor applications and systems within containers. This process is known as containerization. Docker Swarm is a clustering, scheduling, and orchestration tool for systems and environments that run on multiple and scalable Docker containers.

A Docker container is launched by running a Docker image which is an executable package that includes everything needed for running an entire application: code, runtime, libraries, environment variables, and configuration files. A container is a runtime instance of a Docker image.

You can run multiple containers at the same time on the same instance, or a cluster swarm of instances, and the containers are managed by Docker instead of an operating system's hypervisor. This provides redundancy and failover if one or more cluster nodes experience issues.

Docker is lightweight and efficient and can manage the most complex systems built up of multiple applications. You can build Docker containers locally, deploy them to the cloud, and run them anywhere; scaling up and down wherever necessary.

Docker is easy to set up, install, and run on a single ECS instance. A large-scale containerized environment running industry-level applications and systems needs a reliable and scalable orchestration and monitoring system. Alibaba Cloud's Container Service provides system administrator and DevOps teams with the clustered architectures they need to manage extensive containerized environments.

Why Do I Need to Create a Cluster?

Before we can install a suite of running Docker containers with Alibaba Cloud's Container Service, we need to have an Alibaba Cloud Container Service Docker Swarm cluster ready and available for implementing our containerized systems.

This tutorial explains the preliminary step of building out such a cluster. Our following tutorial will show you how to implement Docker images on the Docker Swarm cluster with Alibaba Cloud's Container Service.

Docker Container-Centric Commands for Beginners: Part 1

This tutorial provides a quick demonstration of the 25 Docker commands that can be applied against containers.

The article is structured so that you get to use the following 25 commands at least once each. This will help provide a better understanding of containers from a high-level perspective, such as what containers are and what you can do with them.

Bash Aliases

There are 25 docker container commands, and you do not want to type those words repeatedly. Therefore we need aliases.

Suggestion:

alias dock='docker container'

Its easier for me to type than docc.

alias docv='docker volume'

alias doci='docker inspect'

alias docm='docker image'

alias psa='docker ps -a'

alias d='docker '

Docker Pull Alpine:3.8

If you know you already have the Alpine 3.8 Docker image you don't need to do anything here.

Otherwise enter at shell

docker pull alpine:3.8

to get the Alpine image downloaded onto your computer.

Docker Container: Create and Run
Let's create a container so that we can apply those 25 commands against it.

There are several ways to create running containers, we will use create and run here.

Docker Container Resource Management: CPU, RAM and IO: Part 1

This tutorial aims to give you practical experience of using Docker container resource limitation functionalities on an Alibaba Cloud Elastic Compute Service (ECS) instance, including:

· CPU quotas
· RAM quotas
· IO bandwidth quotas

Prerequisites

You need access to an ECS server with a recent version of Docker already installed. If you don't have one already, you can follow the steps in this tutorial.

These resource limit tests use 20 - 30 MB of RAM so even a server with only a total RAM of 512MB will do.

The CPU tests are done on a server with only 2 cores. You will get more interesting results - for one of the tests - if your server has 4 cores or more.

Some of the CPU tests hog all CPUs for 15 seconds. It would be great for your teammates if you did this tutorial directly on your computer and not on the shared development server.

I am writing this tutorial using CentOS. You can use Debian / Ubuntu. 99% of this tutorial will work on any Linux distro since it mostly uses Docker commands.

You need a very basic understanding of Docker, images, containers and using docker run and docker ps -a.

Clean Up Preparation
It will really help if you have only a few ( preferably no ) containers running. That way you can easily find your tutorial container in docker ps -a output lists.

So stop and prune all the containers you do not need running.

You can quickly do that ( in your DEVELOPMENT environment ) using:

docker stop $(docker ps -a -q) #stop ALL containers

To now remove all containers, run

docker rm -f $(docker ps -a -q) # remove ALL containers

Creating an Alibaba Cloud Container Service Application with Docker Swarm

In this tutorial, we'll show you how to create an Alibaba Cloud Container Service application environment running on Docker containers managed by a Swarm cluster built up on Alibaba Cloud Elastic Compute Service (ECS) instances that we have already set up in a previous tutorial.

In the past, developers had to install, run, and monitor their development and production system environments on racks of physical machines in gigantic server rooms. Nowadays, new containerization technology with virtual management tools, such as Docker Swarm and Kubernetes, allows developers to manage and monitor their production and development environments running collections of Docker application containers directly through Alibaba Cloud's Container Service, using its console web-based user interface.

What Is Alibaba Cloud's Container Service?

Alibaba Cloud's Container Service is a scalable, high-performance, container management product that allows you to orchestrate and manage containerized application lifecycles with either Docker Swarm or Kubernetes. Container Service comes with an automatic built in Server Load Balancer that is installed Pay-As-You-Go.

Alibaba Cloud's Container Service offers multiple application release methods, including continuous integration, and also supports a microservices architecture. By offering a simplified user interface console setup for a container cluster, which integrates with Alibaba Cloud's virtualization, storage, network, and security services, Alibaba Cloud's Container Service is the perfect cloud environment for running, managing, and monitoring containerized application environments.

What Is Docker Swarm?

Docker is an open source, virtualization management tool that allows you to develop, deploy, manage, and monitor applications and collections of applications that run within containers. This process is known as containerization. Docker Swarm is a clustering, scheduling, and orchestration tool for such systems and environments that are running on multiple and scalable Docker containers.

A Docker container is launched by running a Docker image which is an executable package that includes everything needed for running an entire application: code, runtime, libraries, environment variables, and configuration files. A container is a runtime instance of a Docker image.

You can run multiple containers at the same time on the same instance, or on a Docker Swarm cluster of instances. The running containers are managed by Docker instead of an operating system's hypervisor; and Docker, unlike a hypervisor, provides redundancy and failover if one or more of the cluster nodes experience any problems.

Docker is lightweight and efficient and can manage complex systems built up of multiple application images. You can build Docker containers locally, or deploy them to the cloud, and you can run them anywhere; scaling up and down wherever necessary.

Docker is easy to set up, install, and run on a single Alibaba Cloud ECS instance. A large-scale containerized environment running industry level applications and systems needs a reliable and scalable orchestration and monitoring system. Alibaba Cloud's Container Service provides system administrators and DevOps teams with the vast clustered architectures they need to manage extensive containerized environments.

Why Do We Need a Cluster?

Before we can install a suite of running Docker containers with Alibaba Cloud's Container Service Docker Swarm option, we need to have an Alibaba Cloud Container Service Docker Swarm cluster ready and available for implementing our containerized systems.

In a previous tutorial, we showed you how easy it is to set up a Docker Swarm cluster for running a containerized environment with Alibaba Cloud's Container Service. We will use the same running cluster in this tutorial to build out an application environment. We will build an environment with a web server built from an image, and a web application built from an orchestration template, both coming as part of the Alibaba Cloud's Container Service product offerings.

Related Courses

Introduction to Docker Container

This course introduces the basic concepts and features of docker container technology, then showes the steps of basic installation and some frequently used commands. At the same time introduces the the basic concepts and architecture of container service on alibaba cloud, and then shows the steps of container based application creation procedure from scratch.

Implement Blue-Green Deployment with Container Service

Through this certification course, you will understand the basic differences between the container and the virtual machine environment, learn Kubernetes cluster main components, and learn how to use deployment and service to achieve the application of the blue-green deployment.

Related Market products

Introduction to Docker Container

This course is aiming to provide comprehensive introduction of docker container technology and the container service on alibaba cloud as well.

Using Kubernetes to Manage Containers and Cluster Resources

Through the introduction of basic knowledge of Kubernetes and Alibaba Cloud Container Service, this course enables learners to quickly get started with Container Service for Kubernetes.

Using Swarm to Orchestrate and Manage Containers

Through the introduction of Docker, Swarm and Alibaba Cloud Swarm, this course enables learners to quickly get started with Container Service for Swarm.

Related Documentation

Docker container operations

EDAS supports Docker-based deployment. After Docker-based deployment, you can view the Docker container status on the server.

  1. Go to the Docker container operation page. Log on to the server where a Docker application is deployed and run docker ps to view the containers that are enabled. Run docker exec -ti $container_id bash to go to a Docker container.
  2. View the log. You can conveniently view the application deployment log on the EDAS console. To view the log directly on the server, you can run the docker inspect --format {{.LogPath}} $container_id command to locate the application log path of the corresponding container.

How to increase data disks for Container Service Docker?

Docker data is stored on disks by using the union file system. If the number of containers or images needing to be run on the machines is continuously increased, the disk size may not meet the requirements. In this situation, increase the data disks to expand the storage space for Docker data directory.

Docker data directory

For Docker, the container and image data is stored in the /var/lib/docker directory by default. You can check the currently occupied disk size of this directory by running the du command.

Change Docker data disk

Many Docker images are big. Therefore, several images might occupy large disk space, which leads to insufficient disk space. By increasing the data disks for the Docker data directory, the requirements of increasing images or containers continuously can be met.

Related Products

Elastic Container Instance (ECI)

Elastic Container Instance (ECI) is an agile and secure serverless container instance service. You can easily run containers without managing servers. Also you only pay for the resources that have been consumed by the containers. ECI helps you focus on your business applications instead of managing infrastructure.

Container Service for Kubernetes (ACK)

A fully-managed service compatible with Kubernetes to help users focus on their applications rather than managing container infrastructure

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments