且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Docker中使用新的jar文件创建映像?

更新时间:2023-09-30 14:14:52

您未定义用于传入连接的端口,boot2docker将端口80映射到范围49153至65535中的第一个空闲的高范围端口(请参阅操作方法).在boot2docker中

You did not define port for incomming connections, and boot2docker maps port 80 to the first free high-range port in range 49153 to 65535 (see how to do it in boot2docker and docker).

这是对我有用的设置(尽管在Windows上,但对于OSX同样适用),我已将您的应用程序映射到端口8000,请随时进行更改:

Here is the setup that worked for me (on Windows, though, but the same thing is for OSX), I have mapped your application on port 8000, please feel free to change it:

c:\>boot2docker init
Virtual machine boot2docker-vm already exists
c:\>boot2docker up
Waiting for VM and Docker daemon to start...
..........ooo
Started.
Writing C:\Users\xyz\.boot2docker\certs\boot2docker-vm\ca.pem
Writing C:\Users\xyz\.boot2docker\certs\boot2docker-vm\cert.pem
Writing C:\Users\xyz\.boot2docker\certs\boot2docker-vm\key.pem
Docker client does not run on Windows for now. Please use
    "boot2docker.exe" ssh
to SSH into the VM instead.
c:\>boot2docker ssh -L 0.0.0.0:8000:localhost:8000
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.3.2, build master : 495c19a - Mon Nov 24 20:40:58 UTC 2014
Docker version 1.3.2, build 39fa2fa
docker@boot2docker:~$ docker run -it -p 0.0.0.0:8000:80 --name imgcon33 img33/img33

此设置将您的应用程序映射如下: imgcon33(端口80)-> docker(8000)-> boot2docker(8000)-> localhost(8000)

This setup maps your application like this: imgcon33 (port 80) -> docker (8000) -> boot2docker (8000) -> localhost (8000)

如果您从boot2docker运行curl,那么一个简单的

If you run curl from boot2docker, then a simple

curl localhost:80

应该足够了. 但是,如果要从主机容器(托管boot2docker的容器)访问应用程序,则必须以以下方式运行它:

should be enough. But if you want to access your application from host container (the one that hosts boot2docker), you have to run it as

curl localhost:8000