目錄
概念
Docker
Docker is the world's leading software container platform
更多參考What is Docker
Image
An image is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the code, a runtime, libraries, environment variables, and config files
互動(dòng): Windows鏡像和Windows系統(tǒng)有何關(guān)系和區(qū)別?
Container
A container is a runtime instance of an image—what the image becomes in memory when actually executed. It runs completely isolated from the host environment by default, only accessing host files and ports if configured to do so.
Containers vs. virtual machines
- Virtual Machine diagram
dcoker-01.png
- Container diagram
dcoker-02.png
互動(dòng): Docker能否運(yùn)行在Windows系統(tǒng)? 如何做到的?
安裝
系統(tǒng)源
sudo apt install -y docker.io
sudo docker run hello-world
官方源
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y docker-ce
加速器
更多參考Docker 加速器
實(shí)戰(zhàn)Nginx
下載Image
docker images
docker search nginx
docker pull nginx
更多參考Docker CLI
創(chuàng)建Container
docker ps # docker ps --all
docker run --name nginx-demo -d nginx
登錄Container
docker exec -it nginx-demo /bin/bash
刪除Container
docker rm -f nginx-demo
Expose Port
docker run --name nginx-demo -p 8001:80 -d nginx
curl http://localhost:8001/
Copy File
vim index.html
<html>
<body>
Copy File
</body>
</html>
docker cp ./index.html nginx-demo:/usr/share/nginx/html
curl http://localhost:8001/
Use Volume
docker run --name nginx-demo -p 8001:80 -v ~/docker/nginx-demo:/usr/share/nginx/html -d nginx
更多參考Use volumes
實(shí)戰(zhàn)WordPress
下載Image
docker pull mysql && docker pull wordpress
創(chuàng)建Container
docker run --name mysql-demo -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql
docker run --name wordpress-demo -p 8002:80 --link mysql-demo:mysql -d wordpress
更多參考docker run
下一步
更多文章, 請(qǐng)支持我的個(gè)人博客