Install, compile, and deploy Docker from scratch

Source: Internet
Author: User
Tags curl port number docker ps docker hub docker run
Introduction

Main introduction to how to deploy Docker from the base system Debian
About Docker Basics There's a link to installing Docker in the relevant material.

1. Add apt source using root user identity
Add public key to grant the Docker installation source credit

$ Curl-s ' https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e ' | sudo apt-key add--import

Installing APT's HTTPS support

sudo apt-get update && sudo apt-get install Apt-transport-https

Installation of Image virtualization support

sudo apt-get install-y linux-image-extra-virtual

Add Apt Source

echo "Deb Https://packages.docker.com/1.11/apt/repo ubuntu-trusty main" | sudo tee/etc/apt/sources.list.d/docker.list

Installing Docker

Apt-get Update && apt-get install Docker-engine

To see if the installation was successful

Docker info

The installation was successful when you saw the following information

Containers:1
 running:1
 paused:0
 stopped:0
images:15
Server version:1.11.2-cs3
Storage Driver:aufs
 Root Dir:/var/lib/docker/aufs
 backing Filesystem:extfs
 dirs:17
 Dirperm1 Supported: True
Logging driver:json-file
Cgroup driver:cgroupfs
Plugins: 
 volume:local
 Network: Bridge NULL host
Kernel version:3.16.0-4-amd64
Operating System:debian gnu/linux 8 (Jessie)
OSType: Linux
architecture:x86_64
cpus:1
total memory:3.871 GiB
Name:debian
ID:IWCZ:QXXZ:VBUN: Umf7:xrg3:cmxb:6luo:f65c:oa6b:75qq:7sew:3okt
Docker Root Dir:/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
registry:https://index.docker.io/v1/
making the underlying software image Jdk8

Preferred to install JDK, installed here using JDK8
Download JDK
Write dockerfile in the same directory

From Registry.cn-hangzhou.aliyuncs.com/yuuji/debian:latest

ADD jdk-8u101-linux-x64.tar.gz/opt

ENV JAVA_ home/opt/jdk1.8.0_101

workdir/usr/bin
RUN ln-s/opt/jdk1.8.0_101/bin/java java

The directory structure is as follows:

Compiling the publication

Docker build-t Jdk8. 

You can also create a warehouse on a Docker hub server to publish to a remote

Docker build-t Registry.cn-hangzhou.aliyuncs.com/xxx/jdk8. 
Docker Push REGISTRY.CN-HANGZHOU.ALIYUNCS.COM/XXX/JDK8

You can go to remote view after publishing, or you can use the command to view

Docker images
Mave3

Based on JDK8 we are making a MAVEN3 image, the steps above, I will not list the orders;
Dockerfile

From Registry.cn-hangzhou.aliyuncs.com/yuuji/jdk8:latest

add settings.xml/root/.m2/settings.xml
add Apache-maven-3.3.9-bin.tar.gz/opt

workdir/usr/bin
RUN ln-s/opt/apache-maven-3.3.9/bin/mvn mvn

Publish to see if a software error has been successfully made

What to do if you encounter an error in the process
Use the command Docker images if you see none, you can use the command Docker IMAGE ID to clean up;
If the image is not cleaned up, use Docker ps-a and find the container used.
Then the Docker RM CONTAINER ID compiles the project with the deployment

Here is the first item that can be started by spring-boot
Then build the Dockerfile in the project and directory

From Registry.cn-hangzhou.aliyuncs.com/yuuji/maven3:latest

EXPOSE 7001

RUN mkdir-p/opt/leona
workdir/ Opt/leona
ADD./opt/leona

RUN mvn clean install-dmaven.test.skip

CMD ["Java", "-jar", "target/ Leona.jar "]

Port number 7001 is your spring-boot web configuration

The structure is as follows:

Then compile the image with the software, here I will not publish to the remote

Docker build-t xxx.

The final local warehouse Docker images
Deployment

The image of the software and the program has been compiled and the next step is to deploy

Docker run-d-P 7001:7001 xxx

Check Curl localhost:7001

<! DOCTYPE html>

is not very simple. 233

The specific parameters do not explain, you can check it yourself;

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.