Docker install configuration Java Tomcat Runtime environment

Source: Internet
Author: User
Tags commit curl ssh port number ssh access ssh server docker ps docker run

Environment

All environments in this article, VMware Workstation running UBUNTU-13.10-SERVER-AMD64, note that the 64-bit system, in theory, other virtual machines are completely feasible.

Install Docker

The Docker 0.7 version requires Linux kernel 3.8 support and requires a Aufs file system.


# Check to see if AUFS is installed
sudo apt-get update
sudo apt-get install linux-image-extra-' uname-r '
# Add Docker repository key
sudo sh-c "WGET-QO-HTTPS://GET.DOCKER.IO/GPG | Apt-key Add-"
# Add Docker repository and install Docker
sudo sh-c "Echo Deb Http://get.docker.io/ubuntu Docker main >/etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install Lxc-docker
# Check if Docker has been installed successfully
sudo docker version
# Terminal Output Client version:0.7.1
Go version (client): go1.2
Git commit (client): 88df052
Server version:0.7.1
Git commit (server): 88df052
Go version (server): go1.2
Last Stable version:0.7.1
get rid of sudo.
In Ubuntu, in the implementation of Docker, each time to enter sudo, and enter the password, very tiring, here fine-tuning, the current user to execute the right to add to the corresponding Docker user group.

# Add a new Docker user group
sudo groupadd Docker
# Add the current user to the Docker user group, and note that the Yongboy for Ubuntu Server logon username
sudo gpasswd-a yongboy Docker
# Restart Docker background monitoring process
sudo service docker restart
# after reboot, try it and see if it takes effect
Docker version
#若还未生效, the system reboots, and it takes effect
sudo reboot

Install Docker run Instance-ubuntu virtual machine
Docker installation completed, background process also automatically started, you can install the virtual machine instance (here directly with the official demo of the use of the learn/tutorial image as an example):

Docker Pull Learn/tutorial

After the installation is complete, look at the effect

Docker Run Learn/tutorial/bin/echo Hello World

Interactive access to newly installed virtual machines

Docker Run-i-T Learn/tutorial/bin/bash

will see:

root@51774a81beb3:/#

The description has entered an interactive environment.
Installing an SSH Terminal Server
Easy access to our external SSH client login


Apt-get Update
Apt-get Install Openssh-server
Which sshd
/usr/sbin/sshd
Mkdir/var/run/sshd
passwd #输入用户密码, I set it to 123456 for easy SSH client Login
Exit #退出

Gets the instance container ID that was just manipulated


#docker ps-l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51774A81BEB3 Learn/tutorial:latest/bin/bash 3 minutes ago Exit 0 Thirsty_pasteur

You can see that the container ID for the current operation is: 51774A81BEB3. Note that once all operations have been made, they need to be submitted for storage for SSH access:


Docker commit 51774A81BEB3 Learn/tutorial

This mirror instance will run for a long period of time in the next session:

Docker run-d-P 22-p 80:8080 learn/tutorial/usr/sbin/sshd-d

The SSH server running in the Ubuntu container consumes 22 ports, and-p 22 is specified. -P 80:8,080 means that we will run Tomcat with 8080 ports, but the port (outside the container) map is 80.
Now, check to see if it runs successfully.


#docker PS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
871769a4f5ea learn/tutorial:latest/usr/sbin/sshd-d about a minute ago up about a minute 0.0.0.0:49154->22/tcp, 0.0.0. 0:80->8080/tcp Focused_poincare

Note that the assigned random SSH connection port number is 49154:


SSH root@127.0.0.1-p 49154

Input can be password, is it possible to enter the? Once you control ssh, the rest is simple, install the JDK, install tomcat, whatever you want. The following is an installation script:


# Install Oracle JDK 7 on Ubuntu 12.04
Apt-get Install Python-software-properties
Add-apt-repository Ppa:webupd8team/java
Apt-get Update
Apt-get install-y wget
Apt-get Install Oracle-java7-installer
Java-version
# download Tomcat 7.0.47
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
# Unzip, run
Tar xvf apache-tomcat-7.0.47.tar.gz
CD apache-tomcat-7.0.47
bin/startup.sh

By default, Tomcat consumes 8080 ports, and just when the mirror instance is started, the-p 80:8080,ubuntu Mirror Instance/container is specified, the 8080 port is opened, and the map to the host port is 80. Know the host IP address, it is free to access. On the host, through the Curl test can be:

Curl http://192.168.190.131

Of course, you can also use the browser to access it.
In reality, Tomcat may not be able to open the 80 port directly to the Nginx/apache or behind the firewall, just for demonstration.

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.