Bluemix很慢启动Spring Boot应用程序,挂起

时间:2015-02-04 21:29:51

标签: docker spring-boot ibm-cloud

我正在尝试使用Docker镜像将简单的Spring Boot应用程序部署到Bluemix 该映像基于dockerfile/java:oracle-java8并在我的本地Linux VM上运行完美 - 它在10-30秒内启动 但是,在云中运行相同映像的Blumix容器需要10分钟以上才能启动。 Bluemix控制台页面显示状态为Running,但过去10分钟没有进度(按日志判断)。我使用sudo ice logs -o myContainer命令获取以下日志(注意时间间隔):

Target is container cloud. Invoking cloud service...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v1.2.1.RELEASE)[0;39m

[2m2015-02-04 21:07:49.006[0;39m [32m INFO[0;39m [35m1[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.dash.nlpHighlight.web.App           [0;39m [2m:[0;39m Starting App with PID 1 (/opt/highlighter/highlighter-0.0.1.jar started by root in /opt/highlighter)
[2m2015-02-04 21:07:49.057[0;39m [32m INFO[0;39m [35m1[0;39m [2m---[0;39m [2m[           main][0;39m [36mationConfigEmbeddedWebApplicationContext[0;39m [2m:[0;39m Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5aa60e57: startup date [Wed Feb 04 21:07:49 UTC 2015]; root of context hierarchy
[2m2015-02-04 21:07:52.773[0;39m [32m INFO[0;39m [35m1[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.f.s.DefaultListableBeanFactory    [0;39m [2m:[0;39m Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]

使用sudo ice inspect myContainer我得到:

Target is container cloud. Invoking cloud service...
{
    "Config": {
        "AttachStderr": "",
        "AttachStdin": "",
        "AttachStdout": "",
        "Cmd": [
            "date"
        ],
        "Dns": "",
        "Env": {
            "group-id": "0000",
            "space-id": "5588d535-a208-4cd2-be05-db781af48ada",
            "tagformat": "space-id group-id uuid",
            "tagseparator": "_"
        },
        "Hostname": "",
        "Image": "registry-ice.ng.bluemix.net/myOrg/myImage:latest",
        "Memory": 256,
        "MemorySwap": "",
        "OpenStdin": "",
        "PortSpecs": "",
        "StdinOnce": "",
        "Tty": "",
        "User": "",
        "VCPU": 1,
        "Volumes": [],
        "VolumesFrom": "",
        "WorkingDir": ""
    },
    "Created": "2015-02-04T21:35:17Z",
    "HostConfig": {
        "Binds": "null",
        "CapAdd": [],
        "CapDrop": [],
        "ContainerIDFile": "",
        "Links": [],
        "LxcConf": [],
        "PortBindings": {},
        "Privileged": "false",
        "PublishAllPorts": "false"
    },
    "HostId": "c4cc40876ba4db63069eb35d061670783146287b3d9ca5155dedf1be",
    "Human_id": "myContainer",
    "Id": "fa15e14d-ffe2-4621-b81a-579a60b52936",
    "Image": "ecbb9431-822e-4e74-8a04-5b942743a42c",
    "Name": "myContainer",
    "NetworkSettings": {
        "Bridge": "",
        "Gateway": "",
        "IpAddress": "172.16.46.71",
        "IpPrefixLen": 0,
        "PortMapping": "null",
        "PublicIpAddress": "129.41.249.63"
    },
    "Path": "date",
    "ResolvConfPath": "/etc/resolv.conf",
    "State": {
        "ExitCode": "",
        "Ghost": "",
        "Pid": "",
        "Running": "true",
        "StartedAt": "",
        "Status": "Running"
    },
    "Volumes": []
}

最初我使用ice run myContainer myImage启动容器。我停下来启动了容器,但它没有解决问题。

以下是Docker文件的内容:

FROM dockerfile/java:oracle-java8
ADD myJar-0.0.1.jar /opt/myFolder/
ADD application.properties /opt/myFolder/
EXPOSE 8080
WORKDIR /opt/myFolder/
CMD ["java", "-jar", "-Xmx1500m", "myJar-0.0.1.jar"]

1 个答案:

答案 0 :(得分:0)

将端口绑定到您的应用程序似乎存在问题。

在Dockerfile中,您需要以下内容。

EXPOSE

其中port为22,80,443,9080或9443。

此外,您需要定义一个命令来启动您的应用程序。

CMD [ “....”]

这是https://www.ng.bluemix.net/docs/#services/Containers/index.html的第6步。

相关问题