Two methods of Web project Docker

Source: Internet
Author: User
Tags custom name docker run

The two methods described in the title are actually two ways to create a Docker image

First: After starting the mirror, go into the container, move the required software or items into the container, install or deploy, and then exit.

The second kind: Write Dockerfile, overlay the required mirrors layer by layer, for example, we want to deploy the project, we can first download an Ubuntu base image, then overlay the JDK, then Tomcat, then the project

I have tried both of these methods, the difference being that the second comparison embodies the image overlay feature of Docker, the first to eventually only one layer of mirroring.

First of all, my previous article has mentioned Dockerfile's writing, this way directly to give a simple dockerfile instance and run the command. Of course, before you write the underlying image, we choose Ubuntu: Run command

Docker search Ubuntu

Note: You can also run the Dockerfile file directly, and the specified base image must exist in the warehouse

The following results are obtained:

NAME DESCRIPTION STARS official Automatedubuntu Ubuntu is a Debian-based Linux operating s ... 4241[OK] Ubuntu-upstart Upstart is an event-based replacement for... 65[OK] Rastasheep/ubuntu-sshd dockerized SSH Service, built on top of ... 29[Ok]torusware/speedus-ubuntu always updated official Ubuntu Docker imag ... 26[Ok]ubuntu-debootstrap debootstrap--variant=minbase--components ... 25[OK] Nickistre/ubuntu-lamp lamp Server on Ubuntu 8[Ok]nuagebec/ubuntu simple always updated Ubuntu Docker images ... 6[Ok]nimmis/ubuntu This is a docker images different LTS vers ... 5[Ok]nickistre/ubuntu-lamp-wordpress lamp on Ubuntu with WP-CLI installed 5[Ok]maxexcloo/ubuntu Docker base image built on Ubuntu with Sup ... 2[Ok]jordi/ubuntu Ubuntu Base Image 1[Ok]admiringworm/ubuntu Base Ubuntu Images based on the official u ... 1[Ok]darksheer/ubuntu Base Ubuntu Image--Updated hourly 1[ok]life360/ubuntu Ubuntu is a debian-based Linux operating s ... 0[Ok]esycat/ubuntu Ubuntu LTS 0[OK]LYNXTP/ubuntu https://Github.com/lynxtp/docker-ubuntu 0 [OK]Widerplan/ubuntu our basic Ubuntu images. 0[Ok]datenbetrieb/ubuntu Custom Flavor of the official Ubuntu base ... 0[Ok]teamrock/ubuntu Teamrock ' s Ubuntu image configured with AW ... 0 [Ok]ustclug/ubuntu Ubuntu image forDocker with USTC Mirror 0[Ok]webhippie/ubuntu Docker Images forUbuntu 0[Ok]ubuntucore/jenkins-ubuntu Jenkins image based on Ubuntu 0[Ok]dorapro/ubuntu Ubuntu Image 0[Ok]konstruktoid/ubuntu Ubuntu Base Image 0[OK]UVATBC/ubuntu ubuntu images with unprivileged user 0 [OK]

Choose the highest-rated first one, or you can choose Other, run:

Docker pull Ubuntu

After waiting for the download to complete, start writing dockerfile:

# version:1.0.02015-10-16 09:04"[email protected]"# Unzip the JDK installation package to /home/jdk1.8. 0_ 51ADD jdk-8u51-linux-x64.tar.gz/home/# Installs the Chinese language Pack #run locale-gen zh_cn. UTF-8/home/jdk1.80_51env CLASSPATH.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jarenv PATH $PATH: $JAVA _home/bin# Set the locale variable env LANG ZH_CN. UTF-8ENV LANGUAGE Zh_cn:zh

As shown, put it well:

  

Then run the command:

Docker BUILD-T Custom name path

The image will begin to be built so that a mirror with the base image and JDK is ready.

Then tomcat and Web projects are installed as above.

The first deployment method will then need to mount the directory locally when the mirror is launched:

Docker Run-i-t-v/root/software/:/mnt/software/53a0016cd0ba/bin/bash

Go inside the system:

Docker Exec-t-I 53a0016cd0ba/bin/bash

can see:

Now you can start to install the software and set the environment variables, because the system is also a common Linux operating environment, so here does not have to write specific installation and environment variable configuration

Finally, after deploying the Web project to the Tomcat directory, write a startup script that is ready to be called when the container starts, and take a look at my image instance:

REPOSITORY TAG IMAGE ID CREATED SIZE192.168.161.2:5000/mq_app latest f59fdf14b64f 3 months ago 381.8Mbmesoscloud/marathon latest e4396ffc8383 3 months ago 561.6Mbyfix/jenkins-master latest aee26ee6e30b 3 months ago 1.262Gbpython Latest 70c16d34e4c83 months ago 689.6Mbwebcenter/ACTIVEMQ latest 87fdf4718a31 3 months ago 446.3Mbhaproxy Latest 26df93f0d4993 months ago 139.1MB192.168.161.2:5000/tomcat latest e3de4da2f84a 3 months ago 357.4Mbredis Latest 4f5f397d4b7c4 months ago 177.6 MB

The first one is the Web project I made, it should be pretty clear. It's been a long time. Some of the details have also been forgotten, please forgive me ...

In addition to the startup script mentioned above, you need to set the port mapping, that is, the-p parameter (you can also set the local network mode, do not expand) so that you can access the ...

Two methods of Web project Docker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.