1 Create a simple hello.c by dockerfile and then do a simple docker image
, this is base image, the base image of the shared host
Create directories, such as the HelloWorld directory, create dockerfile files, write
From scratch
ADD Hello/
CMD ["/hello"]//cmd will exit immediately after running
>docker build-t Liaoyurong/hello-world.
Run Docker run Liaoyurong/hello-world output results
2 The relationship between image and container container, presumably equal to the relationship between class and instance
3 Docer Container ls-a//list of currently running and exited container
4 Docker run-it CentOS//will go directly to CENTOSDE container,
Exit//Exit
5 Docker Container RM containerid (can not write full)
6 Docker Ps-a
Docker Ls-aq//List all Containerid
Docker RM $ (Docker container Ls-aq)//Clean All
7
For example, after making a change in container, exit exits Docker,
Docer Container Ls-a
Find the latest names (a random letter)
Docker commit names xxxx/xxxx//container to be modified and then submitted as image
8 install vim through Dockerfile to CentOS
From CentOS
RUN Yum-install Vim
Then Docker build-t liao/xxxx.
9 Dockerfile Grammar
From scratch//making Baseimage
From CentOS
LABEL version= "1.0"//define related meta data
RUN yum update &&yum install-y ...
Workdir/root Set Current working directory
ADD Hello///Copy to root directory
Add test.tar.gz/Added to root directory and unzip
Workdir/root
ADD Hello Test/hello position in #/root/test/hello
ENV mysql_ver 5.6//Set constant
Run: Execute the command and create a new image LAYER
CMD: Set commands and parameters that are easy to start and execute by default, if
Docker run specifies other commands, the cmd command is ignored,
If multiple cmd is defined, the last one is executed
EntryPoint: Set the command to run when the container starts
One shell format
RUN Apt-get install-y Vim
CMD echo "Hello"
entrypoint echo "Hello"
If the shell format is executed, it can identify parameter substitutions such as $NAME=ABC
EXEC format
RUN ["Apt-get", "Install",.....] Separated by commas
ENV name Docker
entrypoint["/bin/bash", "-C", "Echo Hello $name"]
EntryPoint//Generally make it easy to implement in the form of application service, will be executed;
Docker push xxx/xxxx; Release
Docker pull xxx/xxxx//push
Share dockerfile:
You can associate the library on the GitHub, Dockerhub server from GitHub build, equal to Dockerhub to help you build,
Others are more convinced
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.