Getting started Part 2, Docker Run Issue

Hi all, I’m new to Docker and just getting started.

I am trying to follow the guide to getting started, but am stuck on Part 2 (https://docs.docker.com/get-started/part2/#run-the-app). I built the image like so:

[root@localhost DockerPractice]# docker build -t friendlyhello .
Sending build context to Docker daemon   5.12kB
Step 1/7 : FROM python:2.7-slim
 ---> 7302ff8cae7a
Step 2/7 : WORKDIR /app
 ---> Using cache
 ---> d7e6d640f23c
Step 3/7 : ADD . /app
 ---> Using cache
 ---> 805ca2b355ad
Step 4/7 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
 ---> Using cache
 ---> f1919d0c6d7a
Step 5/7 : EXPOSE 80
 ---> Using cache
 ---> aa7dfc38257b
Step 6/7 : ENV NAME World
 ---> Using cache
 ---> 7f8a47c0a281
Step 7/7 : CMD ["python", "app.py"]
 ---> Using cache
 ---> 41b3277d3613
Successfully built 41b3277d3613
Successfully tagged friendlyhello:latest

I try to run the app but get the container immediately exits and I see no message about python serving my app :

[root@localhost DockerPractice]# docker run -p 4000:80 friendlyhello
[root@localhost DockerPractice]# 

I try running it detached but the container seems to disappear almost immediately.

[root@localhost DockerPractice]# docker run -d -p 4000:80 friendlyhello
e733ec23f8ea7c651642d948c55b78dc8ee2b54de66e9aaf9bc18be95774ffb4
[root@localhost DockerPractice]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost DockerPractice]# 

Any help with this would be greatly appreciated ! :slight_smile:

1 Like

what about :
docker run -itd -p 4000:80 friendlyhello
also give the output of :
docker ps -a

Hi.

Also try and look at “docker logs The-Docker-ID-Returned”

Thanks for the feed back. Here are my results :

[root@localhost DockerPractice]# docker run -itd -p 4000:80 friendlyhello
49780698d41326d7b4925eb44049bf6e562040db4127f6727335597b31f9a0f2
[root@localhost DockerPractice]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost DockerPractice]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
49780698d413        friendlyhello       "python app.py"     25 seconds ago      Exited (0) 24 seconds ago                       gracious_ride
e733ec23f8ea        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         elated_engelbart
00dff38c7f6b        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         practical_blackwell
3bd28d1c78c8        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         optimistic_heyrovsky
9772d17c761f        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         sleepy_engelbart
8382de2778b5        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         loving_hugle
2903da91baae        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         elegant_lumiere
d6d8f4e18cd9        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         cranky_lalande
e57f8c35be4b        friendlyhello       "python app.py"     23 hours ago        Exited (0) 23 hours ago                         awesome_franklin
397be336a044        friendlyhello       "python app.py"     32 hours ago        Exited (0) 32 hours ago                         upbeat_villani

I tried using docker logs nothing is showing up.

[root@localhost DockerPractice]# docker logs 49780698d41326d7b4925eb44049bf6e562040db4127f6727335597b31f9a0f2
[root@localhost DockerPractice]# docker logs 49780698d413

Also in case any of this is relavent :

[root@localhost DockerPractice]# docker info
Containers: 27
 Running: 0
 Paused: 0
 Stopped: 27
Images: 24
Server Version: 18.06.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.16.3-301.fc28.x86_64
Operating System: Fedora 28 (Workstation Edition)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.712GiB
Name: localhost.localdomain
ID: ANB4:S7OR:XH5T:NNWM:V6HY:46BX:ZJVK:RGY7:VJL2:NA5Z:RMJA:F6LJ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
3 Likes

I am also experiencing this behavior. The first time I ran the image I saw an error message but I lost it as it hasn’t shown up again, and I wasn’t expecting it to only show up the first time I ran an image. docker logs -t on these containers prints nothing.

docker info:

Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 15
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d37a609
ID: GH4A:E677:P7BI:4AUA:FFEO:R3U4:QVRI:5LJ7:45CF:3X56:UCEL:QLGA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 22
 Goroutines: 47
 System Time: 2018-11-28T22:17:21.655476Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine