Learn Docker:3 yourself. What to do first after installing Docker

Source: Internet
Author: User
Tags docker hub

I went home this weekend and had a lot of work this week and took a few days off from Docker. Today, I finally finished the task, so I continued to study.
In the previous chapter, the other day, I learned about Docker installation and some basic concepts, such as containers and mirrors. So now that Docker is installed, what can be done with the rest?

Start a Docker container

First, look at the local mirrors below.

sudo docker images


Here I have downloaded 2 images locally. Run a mirror below.

-i-t docker/whalesay /bin/bash

It doesn't matter if there is no image locally, Docker checks to see if there is a local docker/whalesay image, and if the image is not found locally, Docker will go to the official Docker repository for the image in the Docker hub. Once the image is found, the image is downloaded and saved locally.
The above command has two parameters:

    1. -I: Indicates the stdin in the Open container, which is the standard input
    2. -T: Indicates that a pseudo terminal is assigned to the container
Internet

Docker then creates a new container with this image inside the filesystem that is breaking the file system. The newly created container has its own network, and IP is already a bridge interface that can communicate with the host host. This is basically a complete host with a Linux system.

At this point, the host can communicate with the container created by Docker, and we can view the native IP:

Ping the host host in Docker:

You can ping the same, pingdocker in the host host:

There is no problem.

Using containers

With container technology, Docker has a virtual host for us, and consumes only dozens of m of overhead. Pass

hostname

can view host name

You can see that the host name of the container is the ID of the container.
The following attempts to install a package in the container. such as the installation of Vim.

apt-get update && apt-get install vim



When you enter VIM, you are ready to use it.

If the project is to configure the environment, it should be the same reason,
How do I install the software in Docker if the Apt-get is not installed?
This question will continue to be studied in the future.

Exit

Exiting Docker is simple, and the Exit command is fine.
Another problem this time left is that the local Docker download image is not editable. That is, the above-entered Docker container, in which Vim is installed, after exiting, there is no, and the new container ID has changed. Pass

sudo-a

You can view all the Docker records.

You can see that the new container ID is different each time.
So how do we save our changes in the container?

Learn Docker:3 yourself. What to do first after installing Docker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.