中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Docker Light-weight virtualization - for class 2

發布時間:2020-07-29 12:54:54 來源:網絡 閱讀:317 作者:gyrgey18912 欄目:系統運維

Docker class 2 : run the docker image and introduce the docker volume and web server


(1)
we will introduce how to use docker to run in backdround !

<br/>docker run -it -d chusiang/takojs1607 /bin/bash -c "while true; do echo 'hi'; sleep 1; done"

-d means daemon , run in the background! you can use docker ps -a see the docker process which run in the background !
-c means "while true; do echo 'hi'; sleep 1; done" is string
for example , the container ID is f0e
you can use this command to see the logs.

docker logs f0e

(2)
you can use this command to give container name which you run

<br/>docker run -it -d --name test1 chusiang/takojs1607<br/>

--name means the container name

(3)
the data haven't seen when you closed the docker if you close directly
you can use docker voulme to save the data in docker!
on the basis of the first class , we create the environment to show that !
First , you need to change the user for root !

cd /
mkdir /mydata
cd mydata/
echo "hello world" > hello.txt
docker run -it -v /mydata:/data chusiang/takojs1607 /bin/bash
-v means volume
/mydata is local host
/data is docker folder

(4)
if you want to open a new terminal in docker containers which is the same container ID , you can use this command

docker exec -it CONTAINER ID bash

(5)
if you want to remove docker containers automatic after finished the docker container , you can add --rm when you start the docker container!

docker run -it --name test1 --rm chusiang/takojs1607 /bin/bash

(6)
if you want to switch terminal to host, you can tap the control +P +Q in your keyboard. if you want to use docker container , just attach it !

(7)
docker is the Light-weight virtualization , Many packages are not installed in it ! For example : ifconfig ,ping etc.
if your docker is ubuntu , you can use apt-get update , and apt-get install net-tools.
But !! Most important is it will disappear if you restart the docker .
so , you can create a new docker images with the package installed
For example , the container ID is ccea9d4e9655

docker commit cce ubuntu:mv1

then , you can start the docker new images with ifconfig tools!
if you want to remove the docker images , you can use this command

docker image rm IMAGE ID


How to use Web server in docker !?
we want to create the web page in the host virtual machine and map to the docker for starting the web server
For the first , we need to pull the docker images with httpd from docker hub

docker pull httpd

and the document root is /usr/local/apache2/htdocs/

Now, we will create the webpage.

cd /mydata/
echo "this is a index webpage" > index.html
echo "hi" >hi.htm

Start the docker container with apache

docker run -itd --name mywebserver -p 8080:80 -v /mydata:/usr/local/apache/htdocs/ httpd

-p means port
8080 is local port
80 is docker port

you can use curl 127.0.0.1:8080 for test !!!
For important, you can edit the webpage in local !
After edited , the docker web server will update!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

泗洪县| 涞源县| 石屏县| 长宁区| 黄浦区| 阿巴嘎旗| 青川县| 蒲江县| 蓬莱市| 永定县| 涞水县| 新丰县| 乌海市| 孟津县| 台南县| 蒙山县| 肃北| 阜阳市| 桃园市| 博野县| 汤原县| 平邑县| 驻马店市| 巫山县| 信阳市| 双桥区| 广丰县| 新野县| 宝清县| 古交市| 古浪县| 湖南省| 响水县| 龙胜| 上思县| 砀山县| 南投县| 兖州市| 龙泉市| 庄浪县| 西和县|