1. Docker run-it Ubuntu
2. After entering the container, install the SSH service:
sudo apt-get install Openssh-server
It is possible to configure the software source before installing: sudo apt-get update
3. Start the SSH service:/usr/sbin/sshd
4. Generate public key and key for login without password:
Ssh-keygen
All the way to the return, will be generated in the ~/.ssh/folder: Id_rsa, Id_rsa.pub
Transfer id_rsa.pub via SCP to this machine: SCP ~/.ssh/id_rsa.pub [Email protected]:~/pub_key_from_docker
5. Switch back to the physical machine and write the pub_key_from_docker you just sent to the login user's ~/.ssh/authorized_keys
Root:sudo Cat Pub_key_from_docker/root/.ssh/authorized_keys
6. Through the above Settings Docker container can log on to the physical machine without a password, and then the Java SCP in the physical machine can be in the container
7. In the physical machine, the default JDK location can be viewed Whereis Java, combined with the LS-L layer to find the location of the JDK,
In My computer, the location of the JDK is in/USR/LIB/JVM/JAVA-7-OPENJDK-AMD64
8. Switch back to the container and copy the JDK from the physical machine into the container:
scp-r [Email protected]:/usr/lib/jvm//opt/
9. Set Java_home, PATH, and other environment variables in the container:
sudo vi/etc/profile
Added at the end of the file
Export JAVA_HOME=/OPT/JVM/JAVA-7-OPENJDK-AMD64
Export path= $JAVA _home/bin: $PATH
: Wq Save Exit
Source/etc/profile make environment variables effective immediately
10. The problem comes, when I use the test, Java error:
The general meaning is that the shared library file (*.so file) could not be found libjli.so
11. The reason is that Ubuntu in the search for library files will be based on the path location in the/etc/ld.so.conf file to find the library files, not the path contains the library files, will not be found
by command: Find/-name "libjli.so"
Found that the file is in Lib in the JDK
namely:/opt/jvm/java-7-openjdk-amd64/jre/lib/amd64/jli/libjli.so
12. To resolve the above problem, you need to add the path found in 11 to the configuration file/etc/ld.so.conf file
Add/opt/jvm/java-7-openjdk-amd64/jre/lib/amd64 with VI
To the end of the file
13. Finally use the/SBIN/LDCONFIG-V update settings
And then Java is ready to run.
Docker new Ubuntu container, set up SSH and physical machine login