Docker入門

目錄

概念

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.

更多參考Get Started, Part 1: Orientation and setup

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

更多參考Get Docker CE for Ubuntu

加速器

更多參考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è)人博客

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 原文鏈接: http://yangbingdong.com/2017/docker-learning/ Prefa...
    83cb194531a7閱讀 652評(píng)論 0 1
  • Docker是什么? Docker的中文本意是碼頭工人,用于搬運(yùn)貨柜。Docker官網(wǎng)給出的解釋是Docker是世...
    遇石俱焚閱讀 4,747評(píng)論 0 13
  • 微風(fēng)輕揚(yáng),揚(yáng)起嘴角的笑意 溫煦的陽(yáng)光下,藍(lán)色心情 被無(wú)限拉長(zhǎng) 你會(huì)像我一樣的 留戀在一個(gè)個(gè)街道 一扇扇窗外 只因那...
    修鐫閱讀 245評(píng)論 0 0
  • 喜歡一個(gè)人大概就是會(huì)默默地為他做很多事,那是一種最純粹,心甘情愿,不求回報(bào)的默默付出。 我們會(huì)默默地在他書本里夾上...
    小七要快樂閱讀 827評(píng)論 1 3
  • 父母在,不遠(yuǎn)游,游必有方。
    加班了不得閱讀 125評(píng)論 0 1