哪幾個(gè)網(wǎng)站做acm題目最近幾天發(fā)生的新聞大事
文章目錄
- 題目要求:
- 一、創(chuàng)建文檔,編寫Dockerfile文件
- 可以將harbor倉(cāng)庫(kù)去啟動(dòng)先起來(lái)
- 二、運(yùn)行Dockerfile,構(gòu)建nginx鏡像
- 三、推送導(dǎo)私有倉(cāng)庫(kù),也就是我們的harbor倉(cāng)庫(kù)
題目要求:
編寫Dockerfile制作Web應(yīng)用系統(tǒng)nginx鏡像,生成鏡像nginx:v1.1,并推送其到私有倉(cāng)庫(kù)。具體要求如下:
- 基于centos基礎(chǔ)鏡像;
- 指定作者信息;
- 安裝nginx服務(wù),將提供的dest目錄(提供默認(rèn)主頁(yè)index.html)傳到鏡像內(nèi),并將dest目錄內(nèi)的前端文件復(fù)制到nginx的工作目錄;
- 暴露80端口;
- 設(shè)置服務(wù)自啟動(dòng)。
- 驗(yàn)證鏡像。
一、創(chuàng)建文檔,編寫Dockerfile文件
1、創(chuàng)建文檔來(lái)存放本次需要寫入的東西
[root@redhat ~]# mkdir -p dockertest
[root@redhat ~]#
[root@redhat ~]# cd dockertest/
[root@redhat dockertest]#
[root@redhat dockertest]# mkidr test1
[root@redhat dockertest]# cd test1/
2、編寫一個(gè)html的前端文件,內(nèi)容隨便
[root@redhat test1]# vim index.html
[root@redhat test1]#
[root@redhat test1]# cat index.html
hello hello hello hello hello hello hello
3、編寫Dockerfile
[root@redhat test1]# vim Dockerfile
[root@redhat test1]# cat Dockerfile
FROM centos //題目要求從cetenos鏡像
MAINTAINER "Tej <Tej@163.com>" //指定的是創(chuàng)建這個(gè)鏡像的作者信息
ADD http://nginx.org/download/nginx-1.24.0tar.gz /usr/local/src //類似于copy指令,支持使用TAR文件和URL路徑
COPY index.html /usr/share/nginx/ // 從上下文目錄中復(fù)制文件或目錄到容器里指定的路徑
EXPOSE 80 // 端口號(hào)為80端口
CMD ["/usr/sbin/nginx","-g","daemon off"] // CMD指令的首要目的在于為啟動(dòng)的容器指定默認(rèn)要運(yùn)行的程序,且其運(yùn)行結(jié)束后,容器也將終止;不過(guò),CMD指定的命令可以被docker run的命令行選項(xiàng)所覆蓋
可以將harbor倉(cāng)庫(kù)去啟動(dòng)先起來(lái)
[root@redhat ~]# cd /usr/local/harbor/
[root@redhat harbor]# ls
common docker-compose.yml harbor.yml install.sh prepare
common.sh harbor.v2.4.1.tar.gz harbor.yml.tmpl LICENSE
[root@redhat harbor]#
[root@redhat harbor]# ./install.sh
輸入./install.sh 就行,之前的密碼和賬戶都沒(méi)有發(fā)生改變,不要看見(jiàn)remove就急忙退出了,他只是在重新啟動(dòng),
二、運(yùn)行Dockerfile,構(gòu)建nginx鏡像
[root@redhat test1]# vim Dockerfile
[root@redhat test1]# docker build -t nginx:v1.1 ./
[+] Building 43.8s (9/9) FINISHED
出現(xiàn)這個(gè)界面就表示nginx安裝成功了,如果不放心的可以去docker images查看,看鏡像是否運(yùn)行了。
三、推送導(dǎo)私有倉(cāng)庫(kù),也就是我們的harbor倉(cāng)庫(kù)
在harbor倉(cāng)庫(kù)里新建一個(gè)項(xiàng)目, 我這里是叫test1,創(chuàng)建項(xiàng)目就在界面最顯眼的地方,下面第一張圖就是默認(rèn)的,第二張就是已經(jīng)創(chuàng)建好了的。
#首先登錄到私有倉(cāng)庫(kù)
[root@node2 demo01]# docker login -u admin -p Harbor12345 192.168.198.200
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded#給鏡像打上合適的標(biāo)簽
[root@node2 demo01]# docker tag nginx:v1.1 192.168.198.200/test1/nginx
[root@redhat ~]# docker images | grep test1
192.168.11.131/test1/nginx v1.1 d24d91713c2d 56 minutes ago 232MB#推送鏡像到私有倉(cāng)庫(kù)
[root@node2 demo01]# docker push 192.168.198.200/test1/nginx:v1.1
The push refers to repository [192.168.198.200:80/demo01/nginx]
02dfab95c1be: Pushed
74ddd0ec08fa: Pushed
v1.1: digest: sha256:888ed81c26b452ff94686c7709f1a6b668aeb2f2f7f80e4225eb83257428a8a7 size: 736
[root@node2 demo01]#
傳輸完畢!