Deploy the last Hapi to Windows+docker,windowsdocker

Source: Internet
Author: User
Tags docker ps

Objective:

The theory is not much to say, the specific structure to look at the picture. Web here is the previous article developed by the HAPI service, database MySQL, nonsense not much to say, rough painted down, frame composition as follows:

MySQL image pull, config

Database Mirroring Lookup

Docker search MySQL

Not much explanation, here I directly pull the MySQL image, and map the port to host 8087, the database default password settings 123456-d MySQL for just above the mirror name, when the mirror and the container have been created

8087:3306-  e mysql_root_password=123456 -D MYSQL

View images, and containers, Test-mysql already running on the container

Docker images
Docker PS

into MySQL's running environment

Docker exec-it test-mysql/bin/-uroot-p123456

The first sentence executes successfully the root authority enters the container's environment

The above statement I was divided into two paragraphs, can be directly combined use.

To test the connection, enter as follows:

  

show databases;

  

At this time with the host database management tool, the following tips

OK, normal connection, some may fail the connection, the workaround is as follows:

Authorizing the database

' Root '@'%'root' with GRANT OPTION;

Special circumstances may still be unable to use, this time try to change the password, then connect, ok! This is just the situation I met.

set authentication_string = password ('root'where' Root ';

The connection was successful, which means that MySQL in Docker is already accessible in the LAN.

Package project files, generate mirrors, bind databases

Open the project file home directory, create a new Dockerfile, and enter the content as follows

#Dockerfile文件FROM docker.io/node   /home/service  /home/service RUN NPM Install         8888             //Open 8888 Port  "npm"  Start" ]

Note that running the program, such as node's project, we need to configure the same port, also need to configure the site address, as follows:

The configuration is complete, and the image is packaged. Not less, represents the current path

Docker build-t Test-hapi.

  

Run a mirror to establish a connection to the database container

8088:8888 -D Test-hapi

Go to container log to see how it works

// Container ID Docker PS View

Perfect.

OK, the building is complete. The following should be noted:

Container with--link, then the Web application configuration file database connection, should be changed to just Link name, and can not take the port, as follows

Why use localhost, because you mapped the container's address to the host, and mapped the port to the host's 8088, the actual request was reversed to the container address, which is 8888.

The node project may be a bit special, and it needs to be configured as a container's IP:

  

Network, with the Windows system will automatically generate virtual machines, I need containers to access the intranet, configured as follows:

  

Deploy the last Hapi to Windows+docker,windowsdocker

Related Article

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.