Using Dockerfile to create mirrors and build containers

Source: Internet
Author: User
Tags chmod docker ps docker hub docker run
Create Dockerfile (take MySQL 5.7 for example)
The official Dockerfile can be downloaded from the Docker hub, as well as docker-entrypoint.sh
It's too long, but it's on the Docker hub. To create a mirror
Go to the Dockerfile directory and execute the following command:
Docker build-t MySQL.
Note the following point, indicated in the current directory.
Once created, you can see the mirror just created by Docker images.

Here you can see that two mirrors have been generated, one is MySQL, the other is the base image: Debian, build containers
Docker run--name mymysql-d mysql:latest \
>-P 3306:3306-v $PWD/conf/my.cnf:/etc/mysql/my.cnf-v $PWD/logs:/logs-v $PWD/data:/mysql_data \
>-E mysql_root_password=123456
And then through Docker PS, you can see the container just generated:

Parameter description:
-P 3,306:3,306: Maps the container's 3306 ports to 3306 ports on the host.
-V $PWD/conf/my.cnf:/etc/mysql/my.cnf: Mounts the CONF/MY.CNF in the current directory of the host to the container
-V $PWD/logs:/logs: Mount the logs directory under the host's current directory to the/logs of the container
-V $PWD/data:/mysql_data: Mount the data directory under the host's current directory to the/mysql_data of the container
-E mysql_root_password=123456: Initializes the ROOT password into the container
Execute command Docker exec-it Mymysql/bin/bash into the container.
The host name that is displayed is the container ID:

Docker EXEC Parameter Description:
-D: Detach mode: Running in the background
-I: Even if there is no additional to keep stdin open (small white do not know what meaning, seemingly is interactive meaning)
-T: Problems encountered during allocation of a pseudo terminal (TTY)
RPC error is always reported in the process of building a container
Docker:error response from Daemon:rpc Error:code = 2 desc = "OCI runtime error:could no synchronise with container PR Ocess:not a directory ".
I checked online and said that the 32-bit system is incompatible with the problem, but I installed a 64-bit system. I think it is the directory problem, the Docker run to remove the-p parameter to execute, or error, but became docker:error response from Daemon:container command ' docker-entrypoint.sh ' Not found or does not exist ..., cannot find docker-entrypoint.sh file, online Search also did not find the answer. Toss for a long time, only to find that my docker-entrypoint.sh do not have executable permissions, so, on the chmod-x docker-entrypoint.sh, but do not know why docker-entrypoint.sh or not to execute, directly executed the chmod 777 docker-entrypoint.sh, finally can.

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.