Docker教程:Perl应用程序示例

2018-10-1914:23:22后端程序开发Comments4,284 views字数 1659阅读模式

演示如何创建一个Perl应用程序并使用Docker执行,此示例包括以下步骤。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

1.创建一个目录用来组织应用程序文件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~$ mkdir -p /home/yiibai/docker/perl-docker-app
Shell

2.更改进入工作目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~$ cd /home/yiibai/docker/perl-docker-app
Shell

3.创建一个 Dockerfile 文件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

FROM perl:5.20  
COPY . /var/www/php  
WORKDIR /var/www/php  
CMD [ "perl", "index.pl"]
Shell

4.创建一个Perl文件: index.pl文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

print "Hello from perl file\n";
Perl

5.创建Docker映像文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

现在,创建这个Scala应用程序的Docker映像。 以下命令用于创建Docker映像。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~/docker/perl-docker-app$ docker build -t perl-app .
Shell

执行上面命令,输出以下结果 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~/docker/perl-docker-app$ sudo docker build -t perl-app .
[sudo] password for yiibai:
Sorry, try again.
[sudo] password for yiibai:
Sending build context to Docker daemon  3.072kB
Step 1/4 : FROM perl:5.20
5.20: Pulling from library/perl
8b87079b7a06: Pull complete
a3ed95caeb02: Pull complete
1bb8eaf3d643: Pull complete
3e04171ce2e5: Pull complete
0b73d3fea769: Pull complete
ffb34b57cdf2: Pull complete
8eeaf71aee14: Pull complete
72cfc9cbff48: Pull complete
2d693787a8c5: Pull complete
Digest: sha256:5e06bbcf01ed88d6812839bcc7645a3960361a6843e14b6337de2897dfb2863f
Status: Downloaded newer image for perl:5.20
 ---> bbe5a82c1dbe
Step 2/4 : COPY . /var/www/php
 ---> 4b03e9f6baca
Removing intermediate container 822fd298a2bd
Step 3/4 : WORKDIR /var/www/php
 ---> afe356a8d214
Removing intermediate container 920751b0eef1
Step 4/4 : CMD perl index.pl
 ---> Running in a5f1b352be9f
 ---> 774aa9644b86
Removing intermediate container a5f1b352be9f
Successfully built 774aa9644b86
Successfully tagged perl-app:latest
yiibai@ubuntu:~/docker/perl-docker-app$
Shell

6.运行Scala Docker映像文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~/docker/perl-docker-app$ sudo docker run perl-app
Shell

运行docker映像后,执行perl脚本,并在控制台屏幕中打印一条消息,如下所示 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html

yiibai@ubuntu:~/docker/perl-docker-app$ sudo docker run perl-app
Hello from perl file
yiibai@ubuntu:~/docker/perl-docker-app$
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/6914.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/6914.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定