- Deployment with Docker
- Srdjan Grubor
- 361字
- 2021-07-02 23:22:12
Building and running
Now that we went over the whole build configuration, we can create our image and see what we just made:
$ docker build -t web_server .
Sending build context to Docker daemon 17.41kB
Step 1/6 : FROM nginx:latest
---> b8efb18f159b
Step 2/6 : RUN apt-get update -q && apt-get dist-upgrade -yq
---> Running in 5cd9ae3712da
Get:1 http://nginx.org/packages/mainline/debian stretch InRelease [2854 B]
Get:2 http://security.debian.org stretch/updates InRelease [62.9 kB]
Get:3 http://nginx.org/packages/mainline/debian stretch/nginx amd64 Packages [11.1 kB]
Get:5 http://security.debian.org stretch/updates/main amd64 Packages [156 kB]
Ign:4 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:6 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [88.5 kB]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2373 B]
Get:9 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9497 kB]
Fetched 9939 kB in 40s (246 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
---> 4bbd446af380
Removing intermediate container 5cd9ae3712da
Step 3/6 : RUN rm /etc/nginx/conf.d/default.conf
---> Running in 39ad3da8979a
---> 7678bc9abdf2
Removing intermediate container 39ad3da8979a
Step 4/6 : RUN mkdir -p /srv/www/html && chown nginx:nginx /srv/www/html
---> Running in e6e50483e207
---> 5565de1d2ec8
Removing intermediate container e6e50483e207
Step 5/6 : COPY nginx_main_site.conf /etc/nginx/conf.d/
---> 624833d750f9
Removing intermediate container a2591854ff1a
Step 6/6 : COPY test.txt /srv/www/html/
---> 59668a8f45dd
Removing intermediate container f96dccae7b5b
Successfully built 59668a8f45dd
Successfully tagged web_server:latest
Seems like the container build is just fine; let's run it:
$ docker run -d \
-p 8080:80 \
--rm \
web_server
bc457d0c2fb0b5706b4ca51b37ca2c7b8cdecefa2e5ba95123aee4458e472377
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc457d0c2fb0 web_server "nginx -g 'daemon ..." 30 seconds ago Up 29 seconds 0.0.0.0:8080->80/tcp goofy_barti
So far, so good, as it seems to be running fine. Now we will access the container with our browser at http://localhost:8080.

As we were hoping, our server is working and showing us the content of /srv/www/html, but let's click on test.txt to make sure it is working too:

Great, it looks like our plan worked and we have created a high-performance static website hosting server container! Sure, there are many other things we can add to this, but our main goal of extending a sample image to do something useful is a success!
推薦閱讀
- 自動控制工程設(shè)計(jì)入門
- 輕輕松松自動化測試
- Dreamweaver CS3網(wǎng)頁設(shè)計(jì)50例
- 數(shù)據(jù)挖掘?qū)嵱冒咐治?/a>
- Creo Parametric 1.0中文版從入門到精通
- 大數(shù)據(jù)驅(qū)動的設(shè)備健康預(yù)測及維護(hù)決策優(yōu)化
- Red Hat Linux 9實(shí)務(wù)自學(xué)手冊
- Linux內(nèi)核精析
- 手機(jī)游戲策劃設(shè)計(jì)
- MPC5554/5553微處理器揭秘
- 生成對抗網(wǎng)絡(luò)項(xiàng)目實(shí)戰(zhàn)
- 企業(yè)級Web開發(fā)實(shí)戰(zhàn)
- 實(shí)戰(zhàn)Windows Azure
- 工業(yè)機(jī)器人應(yīng)用系統(tǒng)三維建模
- Wireshark Revealed:Essential Skills for IT Professionals