This is a creation in Article, where the information may have evolved or changed.
2015-01-27 WCDJ
Summary: There are more lamp images on the Docker hub, where tutum/lamp mirrors are more famous, this article uses Tutum/lamp as the base image and adds a go compilation environment on it, and then creates and tests a mirror that supports Golang network applications.
The process is as follows:
1, download Tutum/lamp image from Docker hub
root@gerryyang:~# Docker search-s 5 lampname DESCRIPTION STARS Official Automatedtutum/lamp lamp Image-apache listens in port ... [Ok]dockerfiles/centos-lamp 8 [O k]root@gerryyang:~# Docker pull tutum/lamppulling repository tutum/lampb84edafb1623:download complete 511136ea3c5a: Download Complete D497ad3926c8:download Complete ccb62158e970:download complete e791be0477f2:download complete 3680052 C0f5c:download Complete 22093c35d77b:download Complete 5506de2b643b:download complete 47736d0699b6:download complete 5 9fd8a267ae4:download Complete 841e457fbafa:download complete a4764b4cd917:download complete 0541e94da879:download com Plete 4a3d27d06fa4:download Complete 7a8e713e5398:download complete 723faab6a94a:download complete B951305B9A69:DOWNL Oad Complete 09d2bbb9c055:download Complete ccef939b216c: Download Complete 4458c9f101a6:download Complete 889d08af8392:download complete df75de2ea944:download complete ccb86d 616ddf:download Complete Cb81542002b8:download Complete 36ca8ec2e1b6:download complete 4534351c7b4a:download complete 05bcfc7588b0:download Complete 14e5b41d2a83:download Complete 41d45c51a5df:download complete status:downloaded newer Image for tutum/lamp:latestroot@gerryyang:~# Docker imagesrepository tag IMAGE id created VIRTUAL sizetutum/lamp latest b84edafb1623 3 months ago 436.7 MB
2. Start the Tutum/lamp container and test if the service access is OK
root@gerryyang:~# Docker run-d-P 40080:80-p 43306:3306 tutum/ lamp54a001909fd1746a07876c6cba70b681b9826580ce90d7f7f5a22d22226bf6e5root@gerryyang:~# Docker PS ACONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES54A001909FD1 tutum/lamp:latest "/run.sh" 5 seconds ago up 4 seconds 0.0.0.0:40080->80/tcp, 0.0.0.0:43306->3306/TCP Roma Ntic_yonath 3fa70f39af75 ubuntu_sshd_gcc_nginx_gerry:14.04 "/run.sh" about a hour ago up Abou T an hour 0.0.0.0:30022->22/tcp, 0.0.0.0:30080->80/tcp, 0.0.0.0:30443->443/tcp Distracted_wilson 101bc29 5b601 ubuntu_sshd_gcc_apache_gerry:14.04 "/run.sh" 2 hours ago up 2 hours 0.0.0.0:2002 2->22/TCP, 0.0.0.0:20080->80/tcp suspicious_sinousSi cec21c3c0a1f registry:latest "docker-registry" 2 hours ago up 2 hours 0.0.0.0:5000->5000/tcp Boring_torvalds 6906a758711c Ubuntu _sshd_gcc_gerry:14.04 "/run.sh" 2 hours ago up 2 hours 0.0.0.0:10022->22/tcp Determined_kirch
3, mirror-based tutum/lamp:latest using Dockerfile to compile a Golang network service image tutum_lamp_golang_gerry:1.0
Dockerfile source code please see GitHub.
root@gerryyang:~/golang_tutum_lamp# Docker imagesrepository tag IMAGE id created VIRTUAL sizetutum_lamp_golang_gerry 1.0 6b660dc40f2b 2 minutes ago 661.4 mbtutum/lamp latest b84edafb1623 3 months ago 436.7 MB
The image with the Golang app has been created, using the debug.sh script to enter the container to confirm that the service is working properly, such as whether the startup script path is correct and whether the binaries have been generated.
4, start the container in the background, that is, start the Golang service, and pass the external network test
Docker run-d-P 9090:9090 tutum_lamp_golang_gerry:1.0
root@gerryyang:~# Docker PS Acontainer id image command created STATUS ports names49ce9a13a90a UBUNTU_SSHD_gcc_golang_gerry:14.04 "/run.sh" 8 Minutes ago up 8 minutes 0.0.0.0:9001 ->9001/TCP, 0.0.0.0:50022->22/tcp dreamy_bohr dd74c290bfb2 Tutum_ lamp_golang_gerry:1.0 "/run.sh" 8 minutes ago up 8 minutes 0.0.0.0:9090->9090/tcp, 0.0.0.0:50080->80/tcp, 0.0.0.0:53306->3306/tcp gloomy_galileo f24cdc4601f0 tutum/lamp:latest "/run.sh" 8 minutes ago up 8 minutes 0.0.0.0:40080->80/tcp, 0.0.0.0:43306->3306/tcp berserk_nobel 0558ae51d1bb ubuntu_sshd_gcc_nginx_gerry:14.04 "/run.sh" 8 minutes ago up 8 minutes 0.0.0.0:30022->22/tcp, 0.0.0.0:30080->80/TCP, 0.0.0.0:30443->443/tcp high_wozniak 22181d74ab6d ubuntu_sshd_gcc_apache_gerry:14.04 "/run.sh" 8 minutes ago up 8 minutes 0.0.0.0:20022->22/tcp, 0.0.0.0:20080- >80/tcp backstabbing_bell1 1bcd2f542592 registry:latest "Docker-registry" 8 minutes ago up 8 minutes 0.0.0.0:5000->5000/tcp Desperate_ sammet 9454db5b40f2 Ubuntu_sshd_gcc_gerry :14.04 "/run.sh" 8 minutes ago up 8 minutes 0.0.0.0:10022->22/tcp admiring_hypatia
Whether the service can be accessed through the extranet test
Note: When you create a mirror using Dockerfile, the open port of the parent mirror is inherited, but the start command is not inherited, so the service that you want to start is specified in the Run.sh startup script of the sub-image, otherwise the parent mirror's existing service cannot be accessed.