无法使用入口点运行 docker 容器

Posted

技术标签:

【中文标题】无法使用入口点运行 docker 容器【英文标题】:Unable to run the docker container using the entrypoint 【发布时间】:2018-03-15 19:55:35 【问题描述】:

我能够成功地构建和运行这个 docker 容器,但是里面的 asp.net 核心应用程序/微服务无法运行并退出而没有给出任何错误。

这里是 docker 容器的日志。

C:\Work\FloAppCore\Docker-Compose>docker-compose --verbose up -d --build
compose.config.config.find: Using configuration files: .\docker-compose.yml
docker.auth.find_config_file: Trying paths: ['C:\\Users\\flo-engineer-7\\.docker\\config.json', 'C:\\Users\\flo-engineer-7\\.dockercfg']
docker.auth.find_config_file: No config file found
compose.cli.command.get_client: docker-compose version 1.16.1, build 6d1ac219
docker-py version: 2.5.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016
compose.cli.command.get_client: Docker base_url: http+docker://localnpipe
compose.cli.command.get_client: Docker version: KernelVersion=10.0 14393 (14393.1593.amd64fre.rs1_release.170731-1934), Arch=amd64, BuildTime=2017-09-21T23:10:04.946582391+00:00, ApiVersion=1.30, Version=17.06.2-ee-3, MinAPIVersion=1.24, GitCommit=915cbaa, Os=windows, GoVersion=go1.8.3
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
compose.cli.verbose_proxy.proxy_callable: docker info -> u'Architecture': u'x86_64',
 u'BridgeNfIp6tables': True,
 u'BridgeNfIptables': True,
 u'CPUSet': False,
 u'CPUShares': False,
 u'CgroupDriver': u'',
 u'ClusterAdvertise': u'',
 u'ClusterStore': u'',
 u'ContainerdCommit': u'Expected': u'', u'ID': u'',
 u'Containers': 5,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- (u'dockercompose_default')
compose.network.ensure: Creating network "dockercompose_default" with the default driver
compose.cli.verbose_proxy.proxy_callable: docker create_network <- (name=u'dockercompose_default', enable_ipv6=False, ipam=None, labels=u'com.docker.compose.project': u'dockercompose', u'com.docker.compose.network': u'default', driver=None, attachable=True, internal=False, options=None)
compose.cli.verbose_proxy.proxy_callable: docker create_network -> u'Id': u'6765f470d5c0ad7efb38a122e11e1c8ca4f76ceeefe5ad9d3c4e3463b62e05ee',
 u'Warning': u''
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters=u'label': [u'com.docker.compose.project=dockercompose', u'com.docker.compose.oneoff=False'])
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters=u'label': [u'com.docker.compose.project=dockercompose', u'com.docker.compose.service=flousermanagement', u'com.docker.compose.oneoff=False'])
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.service.build: Building flousermanagement
compose.cli.verbose_proxy.proxy_callable: docker build <- (nocache=False, pull=False, cache_from=None, target=None, stream=True, labels=None, network_mode=None, tag=u'dockercompose_flousermanagement', buildargs=, forcerm=False, rm=True, path=u'C:\\Work\\FloAppCore\\FloUserManagement\\bin\\Debug\\netcoreapp2.0\\publish', dockerfile='Dockerfile')
docker.api.build._set_auth_headers: Looking for auth config
docker.api.build._set_auth_headers: No auth config in memory - loading from filesystem
docker.auth.find_config_file: Trying paths: ['C:\\Users\\flo-engineer-7\\.docker\\config.json', 'C:\\Users\\flo-engineer-7\\.dockercfg']
docker.auth.find_config_file: No config file found
docker.api.build._set_auth_headers: No auth config found
compose.cli.verbose_proxy.proxy_callable: docker build -> <generator object _stream_helper at 0x0000000003D75318>
Step 1/8 : FROM microsoft/dotnet:2.0.0-sdk-nanoserver
 ---> b21d0dcac3da
Step 2/8 : ENTRYPOINT dotnet FloUserManagement.dll
 ---> Using cache
 ---> 045d2ee6931f
Step 3/8 : ARG source=.
 ---> Using cache
 ---> 730970d5a20d
Step 4/8 : WORKDIR /floUserManagement
 ---> Using cache
 ---> a49ab14bd6d1
Step 5/8 : ENV ASPNETCORE_URLS http://+:5001
 ---> Using cache
 ---> 53ac819650c8
Step 6/8 : EXPOSE 5001
 ---> Using cache
 ---> 1128b8571494
Step 7/8 : EXPOSE 8080
 ---> Using cache
 ---> bf898070e47c
Step 8/8 : COPY $source .
 ---> Using cache
 ---> 10dca54677f7
Successfully built 10dca54677f7
Successfully tagged dockercompose_flousermanagement:latest
compose.cli.verbose_proxy.proxy_callable: docker close <- ()
compose.cli.verbose_proxy.proxy_callable: docker close -> None
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters=u'label': [u'com.docker.compose.project=dockercompose', u'com.docker.compose.service=flousermanagement', u'com.docker.compose.oneoff=False'])
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.parallel.feed_queue: Pending: set([<Service: flousermanagement>])
compose.parallel.feed_queue: Starting producer thread for <Service: flousermanagement>
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters=u'label': [u'com.docker.compose.project=dockercompose', u'com.docker.compose.service=flousermanagement', u'com.docker.compose.oneoff=False'])
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
Creating dockercompose_flousermanagement_1 ...
compose.parallel.feed_queue: Pending: set([1])
compose.parallel.feed_queue: Starting producer thread for 1
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- (u'dockercompose_flousermanagement')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> u'Architecture': u'amd64',
 u'Author': u'',
 u'Comment': u'',
 u'Config': u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': None,
             u'Domainname': u'',
             u'Entrypoint': [u'dotnet', u'FloUserManagement.dll'],
             u'Env': [u'DOTNET_SDK_VERSION=2.0.0',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- (u'dockercompose_flousermanagement')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> u'Architecture': u'amd64',
 u'Author': u'',
 u'Comment': u'',
 u'Config': u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': None,
             u'Domainname': u'',
             u'Entrypoint': [u'dotnet', u'FloUserManagement.dll'],
             u'Env': [u'DOTNET_SDK_VERSION=2.0.0',
...
compose.service.build_container_labels: Added config hash: fcbc2b05b3778b56210b9b7eaee882bd94227d1fdebf4936737d580c94631241
compose.cli.verbose_proxy.proxy_callable: docker create_host_config <- (device_read_iops=None, mem_swappiness=None, links=[], oom_score_adj=None, blkio_weight=None, cpu_count=None, cpuset_cpus=None, dns_search=None, pid_mode=None, init_path=None, log_config='Type': u'', 'Config': , cpu_quota=None, read_only=None, cpu_percent=None, device_read_bps=None, storage_opt=None, init=None, dns=None, volumes_from=[], ipc_mode=None, mem_reservation=None, security_opt=None, shm_size=None, device_write_iops=None, dns_opt=None, cgroup_parent=None, group_add=None, network_mode=u'dockercompose_default', blkio_weight_device=None, userns_mode=None, tmpfs=None, nano_cpus=None, port_bindings='8080/tcp': ['8080'], '5001/tcp': ['5001'], isolation=None, memswap_limit=None, restart_policy=None, volume_driver=None, devices=None, extra_hosts=None, binds=[u'C:\\Work\\FloAppCore\\FloUserManagement\\bin\\Debug\\netcoreapp2.0\\publish\\data:c:\\floUserManagement\\data:rw'], sysctls=None, pids_limit=None, device_write_bps=None, cap_add=None, mem_limit=None, cap_drop=None, privileged=False, ulimits=None, cpu_shares=None)
compose.cli.verbose_proxy.proxy_callable: docker create_host_config -> 'Binds': [u'C:\\Work\\FloAppCore\\FloUserManagement\\bin\\Debug\\netcoreapp2.0\\publish\\data:c:\\floUserManagement\\data:rw'],
 'Links': [],
 'LogConfig': 'Config': , 'Type': u'',
 'NetworkMode': u'dockercompose_default',
 'PortBindings': '5001/tcp': ['HostIp': '', 'HostPort': '5001'],
                  '8080/tcp': ['HostIp': '', 'HostPort': '8080'],
 'VolumesFrom': []
compose.service.create_container: Creating dockercompose_flousermanagement_1
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (name=u'dockercompose_flousermanagement_1', image=u'dockercompose_flousermanagement', labels=u'com.docker.compose.service': u'flousermanagement', u'com.docker.compose.project': u'dockercompose', u'com.docker.compose.config-hash': 'fcbc2b05b3778b56210b9b7eaee882bd94227d1fdebf4936737d580c94631241', u'com.docker.compose.version': u'1.16.1', u'com.docker.compose.oneoff': u'False', u'com.docker.compose.container-number': '1', host_config='NetworkMode': u'dockercompose_default', 'Links': [], 'PortBindings': '8080/tcp': ['HostPort': '8080', 'HostIp': ''], '5001/tcp': ['HostPort': '5001', 'HostIp': ''], 'Binds': [u'C:\\Work\\FloAppCore\\FloUserManagement\\bin\\Debug\\netcoreapp2.0\\publish\\data:c:\\floUserManagement\\data:rw'], 'LogConfig': 'Type': u'', 'Config': , 'VolumesFrom': [], environment=[], volumes=u'c:\\floUserManagement\\data': , detach=True, ports=[(u'5001', u'tcp'), (u'8080', u'tcp')], networking_config=u'EndpointsConfig': u'dockercompose_default': u'IPAMConfig': , u'Aliases': ['flousermanagement'])
compose.cli.verbose_proxy.proxy_callable: docker create_container -> u'Id': u'09deadd3680a9376ab1771c3034be403b814eeb93adf642b14ee26d2e5a60f39',
 u'Warnings': []
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'09deadd3680a9376ab1771c3034be403b814eeb93adf642b14ee26d2e5a60f39')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> u'AppArmorProfile': u'',
 u'Args': [u'FloUserManagement.dll'],
 u'Config': u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': None,
             u'Domainname': u'',
             u'Entrypoint': [u'dotnet', u'FloUserManagement.dll'],
             u'Env': [u'DOTNET_SDK_VERSION=2.0.0',
                      u'DOTNET_SDK_DOWNLOAD_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.0.0/dotnet-sdk-2.0.0-win-x64.zip',
...
compose.cli.verbose_proxy.proxy_callable: docker disconnect_container_from_network <- (u'09deadd3680a9376ab1771c3034be403b814eeb93adf642b14ee26d2e5a60f39', u'dockercompose_default')
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.cli.verbose_proxy.proxy_callable: docker disconnect_container_from_network -> None
compose.cli.verbose_proxy.proxy_callable: docker connect_container_to_network <- (u'09deadd3680a9376ab1771c3034be403b814eeb93adf642b14ee26d2e5a60f39', u'dockercompose_default', ipv4_address=None, link_local_ips=None, ipv6_address=None, links=[], aliases=['flousermanagement', u'09deadd3680a'])
compose.cli.verbose_proxy.proxy_callable: docker connect_container_to_network -> None
compose.cli.verbose_proxy.proxy_callable: docker start <- (u'09deadd3680a9376ab1771c3034be403b814eeb93adf642b14ee26d2e5a60f39')
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
compose.cli.verbose_proxy.proxy_callable: docker start -> None
Creating dockercompose_flousermanagement_1 ... done
compose.parallel.feed_queue: Pending: set([])
compose.parallel.parallel_execute_iter: Finished processing: <Service: flousermanagement>
compose.parallel.feed_queue: Pending: set([])

这里是 docker 文件。

Dockerfile ==>

   FROM microsoft/dotnet:2.0.0-sdk-nanoserver
   ENTRYPOINT ["dotnet", "FloUserManagement.dll"]
   ARG source=.
   WORKDIR /floUserManagement
   ENV ASPNETCORE_URLS http://+:5001
   EXPOSE 5001
   EXPOSE 8080
   COPY $source .

Dockercompose ==>

   version: '2.1'
   services:
          flousermanagement:
          build: 
                context: ../FloUserManagement/bin/Debug/netcoreapp2.0/publish
                dockerfile: Dockerfile
                ports:
                     - "5001:5001"
                     - "8080:8080"
              volumes:
                   -../FloUserManagement/bin/Debug/netcoreapp2.0/publish/data:c:\floUserManagement\data   

docker-compose 命令正在退出 asp.net 代码,没有任何错误代码。那么如何调试这个问题或者这个问题的可能解决方案是什么。 我已将 dockerfile 中的入口点明确定义为“ENTRYPOINT [“dotnet”,“FloUserManagement.dll”]”,但它无法在容器内执行代码/微服务。

【问题讨论】:

入口点不是必须放在文件末尾吗?另外,码头工人日志在说什么? 删除-d,然后发布日志。另外我假设FloUserManagement.dll 已经构建并且在您的当前目录中可用?因为你没有在 dockerfile 中构建任何东西 【参考方案1】:

@tarun lalwani,感谢您的更新。我删除了 -d --build 选项,docker 服务运行成功。

【讨论】:

以上是关于无法使用入口点运行 docker 容器的主要内容,如果未能解决你的问题,请参考以下文章

Docker - 无法通过脚本删除容器内的文件

无法使用 Spring 数据源参数运行 docker 容器

无法在 CentOS 上运行的 Docker 容器中使用 yum

无法通过 Docker 容器运行 NodeJS 微服务

VS Code 没有为在 Docker 容器中运行的 Node 应用程序打断点

由于出现此错误,无法运行 docker 容器:无法访问 jarfile app.jar