您好,登錄后才能下訂單哦!
[root@localhost ~]# yum install yum-utils device-mapper-persistent-data lvm2 -y
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum install -y docker-ce
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start docker.service
[root@localhost ~]# systemctl enable docker.service
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://w1ogxqvl.mirror.aliyuncs.com"]
}
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker pull centos:7
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7 5e35e350aded 6 weeks ago 203MB
[root@localhost ~]# ls
anaconda-ks.cfg 模板 圖片 下載 桌面 initial-setup-ks.cfg 公共 視頻 文檔 音樂
[root@localhost ~]# mkdir tomcat
[root@localhost ~]# ls
anaconda-ks.cfg tomcat 模板 圖片 下載 桌面
initial-setup-ks.cfg 公共 視頻 文檔 音樂
`接下來的操作需要先把 jdk-8u91-linux-x64.tar.gz 和 apache-tomcat-9.0.16.tar.gz 兩個壓縮包 下載下來之后放在 /root/tomcat/ 目錄下,再直接解壓`
[root@localhost ~]# cd tomcat/
[root@localhost tomcat]# ls
jdk-8u91-linux-x64.tar.gz apache-tomcat-9.0.16.tar.gz
[root@localhost tomcat]# tar zxvf jdk-8u91-linux-x64.tar.gz
[root@localhost tomcat]# tar zxvf apache-tomcat-9.0.16.tar.gz
[root@localhost tomcat]# vim Dockerfile
#基于基礎鏡像
FROM centos:7
MAINTAINER This is tomcat server
ADD jdk-8u91-linux-x64.tar.gz /root
RUN mv /root/jdk1.8.0_91/ /usr/local/jdk1.8
ENV JAVA_HOME=/usr/local/jdk1.8
ENV CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
ENV PATH=$JAVA_HOME/bin:$PATH
ADD apache-tomcat-9.0.16.tar.gz /root
RUN mv /root/apache-tomcat-9.0.16/ /usr/local/tomcat
RUN ln -s /usr/local/tomcat/bin/shutdown.sh /usr/local/bin/;ln -s /usr/local/tomcat/bin/startup.sh /usr/local/bin/
EXPOSE 8080
ENTRYPOINT /usr/local/tomcat/bin/startup.sh && /bin/bash && tail -f /usr/local/tomcat/logs/catalina.out
[root@localhost tomcat]# docker build -t tomcat:centos
[root@localhost tomcat]# docker run -d -P tomcat:centos
61946199e564f72903d17f70d0d1d14627d7b01e5dc80a808936866c494fc1c5
[root@localhost tomcat]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61946199e564 tomcat:centos "/bin/sh -c '/usr/lo…" 12 seconds ago Up 11 seconds 0.0.0.0:32768->8080/tcp quirky_wilbur
#端口為32768
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。