Can't access running Docker container in browser - docker

I'm working behind a corporate proxy. I'm on Windows 10 machine but I'm also running VMware. Inside VMware I'm running a Fedora 28 image. Because I'm behind a corporate proxy I have to run an NTLM proxy server on Windows 10 so that Fedora can connect to the internet.
I have everything set up and I can access the internet and pull docker images perfectly. I'm following this tutorial here on docker-compose.
This is my directory structure:
docker-compose-tut
├── commander
│ └── Dockerfile
└── docker-compose.yml
Dockerfile
FROM node:latest
ENV http_proxy=http://prx:3128
ENV https_proxy=http://prx:3128
ENV ftp_proxy=http://prx:3128
ENV no_proxy=localhost,127.0.0.1
RUN curl -L https://github.com/joeferner/redis-commander/tarball/v0.4.5 | tar zx
RUN npm install -g redis-commander
ENTRYPOINT ["redis-commander"]
CMD ["--redis-host", "redis"]
EXPOSE 8081
docker-compose.yml
backend:
image: redis:latest
restart: always
frontend:
build: commander
links:
- backend:redis
environment:
- ENV_VAR1 = some_value
ports:
- 8081:8081
environment:
- VAR1=value
restart: always
When I run the command docker-compose up -d I get the following output
[root#localhost docker-compose-tut]$ docker-compose up -d
Building frontend
Step 1/10 : FROM node:latest
---> b064644cf368
Step 2/10 : ENV http_proxy http://prx:3128
---> Using cache
---> f70ae2e24003
Step 3/10 : ENV https_proxy http://prx:3128
---> Using cache
---> 12a4e65a3874
Step 4/10 : ENV ftp_proxy http://prx:3128
---> Using cache
---> 77abdce2f8d7
Step 5/10 : ENV no_proxy localhost,127.0.0.1
---> Using cache
---> 467c4f25e4f7
Step 6/10 : RUN curl -L https://github.com/joeferner/redis-commander/tarball/v0.4.5 | tar zx
---> Using cache
---> e3f8b2d8ad64
Step 7/10 : RUN npm install -g redis-commander
---> Running in 3189b0fa1086
npm WARN deprecated ejs#0.8.8: Critical security bugs fixed in 2.5.5
When I enter the command docker-compose ps this is literally the output
Name Command State Ports
------------------------------
When I enter the command docker-compose --services the output is the following:
backend
frontend
If I open the browser and enter http://localhost:8081 the browser says that it can't establish a connection to http://localhost:8081.
What am I doing wrong?

Related

executable not found on docker container

I'm having some issue trying to run a CMD command inside a docker container with a Go application.
This is the output I've got:
golang-api | /bin/sh: ./server: not found
golang-api exited with code 127
This is the Dockerfile
FROM golang:1.18-alpine
RUN apk add g++ && apk add make
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build
EXPOSE 8000
CMD ./server
And this is the Makefile responsible for the build command:
LINUX_AMD64 = GOOS=linux GOARCH=amd64 CGO_ENABLED=1 GO111MODULE=on
migrate:
cd cmd/migrations/$(FOLDER) && go run main.go
build:
cd cmd && $(LINUX_AMD64) go build -a -v -tags musl -o server
And the docker-compose.yml
version: '3.1'
services:
api:
build:
dockerfile: Dockerfile
context: .
container_name: golang-api
ports:
- "8000:8000"
restart: unless-stopped
depends_on:
- db
environment:
- POSTGRES_URL=$POSTGRES_URL
db:
image: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- '5432:5432'
Complete output:
Building api
Sending build context to Docker daemon 74.24kB
Step 1/9 : FROM golang:1.18-alpine
---> 6078a5fce1f5
Step 2/9 : RUN apk add g++ && apk add make
---> Using cache
---> 2a85b9182b80
Step 3/9 : WORKDIR /app
---> Using cache
---> baf1e6b7047c
Step 4/9 : COPY go.mod go.sum ./
---> Using cache
---> 1f2d031bc1b0
Step 5/9 : RUN go mod download
---> Using cache
---> 471d6f24e6a9
Step 6/9 : COPY . .
---> eaa86ff7cb1b
Step 7/9 : RUN make build
---> Running in d6ae6ce79222
cd cmd && GOOS=linux GOARCH=amd64 CGO_ENABLED=1 GO111MODULE=on go build -a -v -tags musl -o server
internal/goos
internal/goarch
internal/race
internal/unsafeheader
internal/goexperiment
runtime/internal/syscall
internal/cpu
sync/atomic
runtime/internal/atomic
internal/itoa
math/bits
internal/abi
runtime/internal/math
runtime/internal/sys
unicode/utf8
unicode
container/list
crypto/internal/subtle
crypto/subtle
unicode/utf16
vendor/golang.org/x/crypto/cryptobyte/asn1
internal/nettrace
vendor/golang.org/x/crypto/internal/subtle
encoding
github.com/mymachine/my-api/internal/controllers/dto
github.com/mymachine/my-api/internal/controllers/helpers
internal/bytealg
math
runtime
internal/reflectlite
sync
internal/testlog
internal/singleflight
math/rand
runtime/cgo
errors
sort
internal/oserror
strconv
path
vendor/golang.org/x/net/dns/dnsmessage
io
crypto/elliptic/internal/fiat
syscall
golang.org/x/text/internal/tag
hash
bytes
strings
hash/crc32
reflect
crypto
crypto/internal/randutil
crypto/hmac
crypto/rc4
net/http/internal/ascii
vendor/golang.org/x/crypto/hkdf
regexp/syntax
github.com/jackc/chunkreader/v2
bufio
crypto/elliptic/internal/nistec
internal/syscall/unix
time
internal/syscall/execenv
vendor/golang.org/x/text/transform
golang.org/x/crypto/pbkdf2
golang.org/x/text/transform
golang.org/x/text/runes
golang.org/x/text/width
regexp
internal/poll
io/fs
context
github.com/mymachine/my-api/internal/entities
github.com/jackc/pgconn/internal/ctxwatch
embed
os
github.com/jinzhu/inflection
github.com/jinzhu/now
internal/fmtsort
encoding/binary
crypto/ed25519/internal/edwards25519/field
crypto/md5
crypto/sha512
crypto/cipher
crypto/sha256
crypto/sha1
encoding/base64
fmt
internal/godebug
encoding/pem
crypto/ed25519/internal/edwards25519
path/filepath
vendor/golang.org/x/crypto/internal/poly1305
io/ioutil
internal/intern
vendor/golang.org/x/crypto/curve25519/internal/field
vendor/golang.org/x/sys/cpu
net/netip
crypto/aes
crypto/des
vendor/golang.org/x/crypto/chacha20
github.com/jackc/pgio
github.com/jackc/pgpassfile
os/exec
os/signal
net
vendor/golang.org/x/crypto/chacha20poly1305
math/big
encoding/hex
net/url
compress/flate
vendor/golang.org/x/crypto/curve25519
log
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/unicode/bidi
vendor/golang.org/x/net/http2/hpack
mime
mime/quotedprintable
compress/gzip
net/http/internal
database/sql/driver
github.com/mymachine/my-api/internal/pkg/errors
encoding/json
github.com/jackc/pgservicefile
vendor/golang.org/x/text/secure/bidirule
golang.org/x/text/internal/language
database/sql
golang.org/x/text/unicode/norm
golang.org/x/text/unicode/bidi
vendor/golang.org/x/net/idna
os/user
crypto/rand
encoding/asn1
crypto/dsa
crypto/elliptic
crypto/ed25519
crypto/rsa
github.com/jackc/pgproto3/v2
golang.org/x/text/internal/language/compact
golang.org/x/text/secure/bidirule
github.com/jackc/pgx/v4/internal/sanitize
golang.org/x/text/language
go/token
vendor/golang.org/x/crypto/cryptobyte
crypto/x509/pkix
gorm.io/gorm/utils
gorm.io/gorm/logger
encoding/gob
go/scanner
golang.org/x/text/internal
github.com/joho/godotenv
crypto/ecdsa
go/ast
golang.org/x/text/cases
github.com/joho/godotenv/autoload
golang.org/x/text/secure/precis
gorm.io/gorm/clause
gorm.io/gorm/schema
gorm.io/gorm
net/textproto
vendor/golang.org/x/net/http/httpproxy
github.com/google/uuid
crypto/x509
github.com/jackc/pgtype
mime/multipart
vendor/golang.org/x/net/http/httpguts
crypto/tls
gorm.io/gorm/migrator
gorm.io/gorm/callbacks
net/http/httptrace
github.com/jackc/pgconn
net/http
github.com/jackc/pgconn/stmtcache
github.com/jackc/pgx/v4
github.com/jackc/pgx/v4/stdlib
gorm.io/driver/postgres
github.com/mymachine/my-api/internal/infrastructure/repository
github.com/mymachine/my-api/configs
github.com/mymachine/my-api/internal/services
github.com/mymachine/my-api/internal/services/transaction
github.com/mymachine/my-api/internal/controllers/handlers/health
github.com/gorilla/mux
github.com/mymachine/my-api/internal/controllers/handlers/transaction
github.com/mymachine/my-api/internal/router
github.com/mymachine/my-api/cmd
Removing intermediate container d6ae6ce79222
---> 621aa6a266de
Step 8/9 : EXPOSE 8000
---> Running in 3cbd17d32c37
Removing intermediate container 3cbd17d32c37
---> 754f71a7753e
Step 9/9 : CMD ./server
---> Running in dfcdc8cd45ce
Removing intermediate container dfcdc8cd45ce
---> 511dbf89a001
Successfully built 511dbf89a001
Successfully tagged my-api_api:latest
Creating my-api_db_1 ... done
Creating golang-api ... done
Attaching to my-api_db_1, golang-api
golang-api | /bin/sh: ./server: not found
The problem was solved.
Somehow,the RUN cd cmd command seemed not generating the file in the expected directory.
Trying with RUN go build cmd/main.go instead of using the makefile worked, as well pointed by #paltaa in the comments.

docker - unable to change directory of volume

I have had no luck with searching for a solution to this.
I have 2 docker containers. frontend, and api. Both need a folder and its contents models to build.
All of these files live in a folder named Website, so the tree would look like:
Website:
-models
-api
-dockerfile
-frontend
-dockerfile
-docker-compose.yml
I am very new to docker, and believe this is how this should be setup, my dockerfile inside of the api directory is like so:
FROM node:latest
RUN mkdir -p /usr/src/app/models
WORKDIR /usr/src/app
COPY ./api/package*.json ./
RUN npm install
COPY ./api/ /usr/src/app
EXPOSE 3000
EXPOSE 3001
CMD [ "npm", "start" ]
This results in 2 models folders being created in side of the docker container, one containing no files located at path (this is where I want my contents):
root#0aa4496c9077:/usr/src/app/models#
and another folder that contains the content that I want it to have, however it is located at:
root#0aa4496c9077:/usr/src/app/src/models#
My question is: how do I map the folder and contents from the Website directory, to the docker container directory /usr/src/app/models?
my actual docker-compose.yml file is as so:
version: "3"
services:
api:
container_name: api
restart: always
build:
context: ./
dockerfile: ./api/dockerfile
ports:
- "3000:3000"
- "3001:3001"
volumes:
- ./models:./models
links:
- mongo
I have attempted changing the volumes path to be absolute, such as:
volumes:
- $PWD/models:/usr/src/app/models
with no luck :(
The build output of running docker-compose build is:
mongo uses an image, skipping
Building api
Step 1/8 : FROM node:latest
latest: Pulling from library/node
Digest: sha256:521df806339e2e60dfdee6e00e75656e69798c141bd2cff88c0c9a9c50ad4de5
Status: Downloaded newer image for node:latest
---> 4495f296c63b
Step 2/8 : WORKDIR /usr/src/app
---> Using cache
---> 94f87a509559
Step 3/8 : COPY ./api/package*.json ./
---> Using cache
---> 3c2e8c17ebf5
Step 4/8 : RUN npm install
---> Using cache
---> 90dc7d21af18
Step 5/8 : COPY ./api/ /usr/src/app
---> 5fa3a2b219ef
Step 6/8 : EXPOSE 3000
---> Running in 6ad5fbea1ed8
Removing intermediate container 6ad5fbea1ed8
---> b2f8f2f9129c
Step 7/8 : EXPOSE 3001
---> Running in 2342665c8da3
Removing intermediate container 2342665c8da3
---> 9f1162670b55
Step 8/8 : CMD [ "npm", "start" ]
---> Running in fc9d766bd5c1
Removing intermediate container fc9d766bd5c1
---> a7267b99b3c2
Successfully built a7267b99b3c2
Successfully tagged website_api:latest
Thank you very much for any help
Use ./models:./models without $PWD , and it's supposed to work.
./modelsis interpreted as relative to the location of the Compose file.
No need to supply absolute path, just relative path and docker-compose will figure it out.

Failing to build docker container on remote host

I have a set of docker containers that are generated from yml files and work ok.
I now want to deploy them to another machine. In another post here I was advised to build the container on the remote host using one of 2 options:
option1 - copy the code to the remote host and apply a modified docker-compose, and build from source using a modified docker-compose
option2 - create an image on local machine, push it to a docker repository, pull it from there, using a modified docker-compose
I'm trying to follow option1 (as a start). I copied the code into the remote host, and modified the Dockerfile, and docker-compose.yml files (snippet1)
The build goes partway through. It downloads the python and postgres images, and starts to process the Dockerfile, but it fails to install the requirements (it fails to install the first requirement - see snippet2)
What can be the problem?
snippet1 - Dockerfile.dair, and docker-compose.yml
cat /home/ubuntu/webServer/web/Dockerfile.dair
FROM python:3.6.1
MAINTAINER User4 <user4#gmail.com>
# Create the group and user to be used in this container
RUN groupadd flaskgroup && useradd -m -g flaskgroup -s /bin/bash flask
# Create the working directory (and set it as the working directory)
RUN mkdir -p /home/flask/app/web
WORKDIR /home/flask/app/web
# Install the package dependencies (this step is separated
# from copying all the source code to avoid having to
# re-install all python packages defined in requirements2.txt
# whenever any source code change is made)
COPY requirements2.txt /home/flask/app/web
RUN pip install --no-cache-dir -r requirements2.txt
# Copy the source code into the container
COPY . /home/flask/app/web
RUN chown -R flask:flaskgroup /home/flask
USER flask
EXPOSE 8000
CMD /usr/local/bin/gunicorn -w 2 -t 3600 -b :8000 project:app
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=run.py
ENV FLASK_DEBUG=1
,
cat /home/ubuntu/construction_overlay/webServer/docker-compose.dair.yml
version: '3'
services:
web:
restart: always
build:
context: ./web
dockerfile: Dockerfile.dair
volumes:
- /home/ubuntu/construction_overlay/webServer/web:/home/flask/app/web
depends_on:
- postgres
nginx:
restart: always
build: ./nginx
ports:
- "80:80"
volumes:
- /home/ubuntu/construction_overlay/webServer/web:/home/flask/app/web
depends_on:
- web
postgres:
restart: always
build: ./postgresql
volumes:
- data1:/var/lib/postgresql
expose:
- "5432"
volumes:
data1:
snippet2 - the build fails to install the requirements
cat /home/ubuntu/webServer/web/requirements.txt
alembic==0.8.8
atomicwrites==1.3.0
attrs==19.1.0
...
,
docker-compose -f /home/ubuntu/webServer/docker-compose.dair.yml up --build -d;
Building postgres
Step 1/4 : FROM postgres:11.3
---> 4e045cb8eecd
Step 2/4 : ENV POSTGRES_USER postgres_user
---> Using cache
---> 400023c58607
Step 3/4 : ENV POSTGRES_PASSWORD postgres_user
---> Using cache
---> 0cf91f314380
Step 4/4 : ENV POSTGRES_DB construction-overlay-db
---> Using cache
---> 151106ecf13b
Successfully built 151106ecf13b
Successfully tagged webserver_postgres:latest
Building web
Step 1/10 : FROM python:3.6.1
---> 955d0c3b1bb2
Step 2/10 : MAINTAINER User4 <user4#gmail.com>
---> Using cache
---> 128d55ddb4e7
Step 3/10 : RUN groupadd flaskgroup && useradd -m -g flaskgroup -s /bin/bash flask
---> Using cache
---> e2c30915fcf5
Step 4/10 : RUN mkdir -p /home/flask/app/web
---> Using cache
---> 8f44dada5953
Step 5/10 : WORKDIR /home/flask/app/web
---> Using cache
---> 04a895c3fe27
Step 6/10 : COPY requirements.txt /home/flask/app/web
---> Using cache
---> 13ab37e789f8
Step 7/10 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 61475950cd73
Collecting alembic==0.8.8 (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1e979262b0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/alembic/
The solution was to add a rule for UDP outbound at the cloud provider
After adding this rule, the pre-requirements install ok
Egress IPv4 UDP 1 - 65535 0.0.0.0/0

Why can't I access container with Dockerfile and but can access with docker-compose?

I am trying to learn Docker. I have a Hello World Django server application. When I try to run my server using a Dockerfile, my server is unreachable. But when I use docker-compose, I am able to access it.
My question is why, especially when they are quite similar.
My Dockerfile:
FROM python:3
# Set the working directory to /app
WORKDIR /bryne
# Copy the current directory contents into the container at /app
ADD . /bryne
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# EXPOSE port 8000 to allow communication to/from server
EXPOSE 8000
# CMD specifcies the command to execute to start the server running.
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# done!
Commands used when running server using Dockerfile:
docker build -t swyne-latest
docker run swyne-latest
Result: Cannot access server at 127.0.0.1:8000
My docker-compose.yml:
version: '3'
services:
web:
build: .
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
container_name: swyne
volumes:
- .:/bryne
ports:
- "8000:8000"
Commands used when running server using docker-compose:
docker-compose up
Result: Able to access my server at 127.0.0.1:8000
Thanks
Edit: Output from Dockerfile build:
$ docker build -t swyne-latest .
Sending build context to Docker daemon 60.15MB
Step 1/6 : FROM python:3
3: Pulling from library/python
05d1a5232b46: Already exists
5cee356eda6b: Already exists
89d3385f0fd3: Already exists
80ae6b477848: Already exists
28bdf9e584cc: Already exists
523b203f62bd: Pull complete
e423ae9d5ac7: Pull complete
adc78e8180f7: Pull complete
60c9f1f1e6c6: Pull complete
Digest: sha256:5caeb1a2119661f053e9d9931c1e745d9b738e2f585ba16d88bc3ffcf4ad727b
Status: Downloaded newer image for python:3
---> 7a35f2e8feff
Step 2/6 : WORKDIR /bryne
---> Running in 9ee8283c6cc6
Removing intermediate container 9ee8283c6cc6
---> 5bbd14170c84
Step 3/6 : ADD . /bryne
---> 0128101457f5
Step 4/6 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
---> Running in 55ab661b1b55
Collecting Django>=2.1 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/32/ab/22530cc1b2114e6067eece94a333d6c749fa1c56a009f0721e51c181ea53/Django-2.1.2-py3-none-any.whl (7.3MB)
Collecting pytz (from Django>=2.1->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
Installing collected packages: pytz, Django
Successfully installed Django-2.1.2 pytz-2018.5
Removing intermediate container 55ab661b1b55
---> dce5400552b2
Step 5/6 : EXPOSE 8000
---> Running in c74603a76b54
Removing intermediate container c74603a76b54
---> ee5ef2bf2999
Step 6/6 : CMD ["python", "manage.py", "runserver", "127.0.0.1:8000"]
---> Running in 4f5ea428f801
Removing intermediate container 4f5ea428f801
---> 368f73366b69
Successfully built 368f73366b69
Successfully tagged swyne-latest:latest
$ docker run swyne-latest
(no output)
I guess it's normal that unlike docker-compose up, docker run swyne-latest does not allow you to access the web application at 127.0.0.1:8000.
Because the docker-compose.yml file (which is read by docker-compose but not by docker itself) specifies many parameters, in particular the port mapping, which should otherwise be passed as CLI parameters of docker run.
Could you try running docker run -p 8000:8000 instead?
Also, I guess that the line command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000" should probably put inside the Dockerfile itself with a CMD or ENTRYPOINT directive, not in the docker-compose.yml file.
Actually, I've just taken a look at the output of your docker build command and there is an orthogonal issue:
the command
CMD ["python", "manage.py", "runserver", "127.0.0.1:8000"]
should be replaced with
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
(See this SO answer for more feedback on this issue, albeit in another language, Java instead of Python.)
As an aside, the complete command to compile the Dockerfile is not docker build -t swyne-latest but docker build -t swyne-latest . (with the final dot corresponding to the folder of the Docker build context).

Docker compose is not starting all containers (possibly Flask related?)

Here's my compose file:
version: '2'
services:
web:
build: ./web
ports:
- "3000:3000"
links:
- api
api:
build: ./api
links:
- db
db:
image: postgres
Here is my Dockerfile for the web service:
FROM node:8.9.3
WORKDIR /app
COPY ./package.json /app
COPY ./server /app/server
COPY ./client /app/client
EXPOSE 3000
ENV PORT 3000
RUN ["npm", "install"]
ENTRYPOINT ["npm", "start"]
And for the api project:
FROM python:3.6
WORKDIR /api
COPY ./requirements.txt /api/requirements.txt
COPY ./src /api/src
EXPOSE 80
ENV PORT 80
RUN ["pip", "install", "-r", "requirements.txt"]
RUN ["python", "src/main.py"]
When I run docker-compose up, only the api service starts. However, if I comment out the api service altogether and run docker-compose up again, both the web and db services start. Is there something wrong with how I've set up the api project? What am I doing wrong?
Just for completeness, here is the starting file for the web project (uses Express)
http.createServer(app).listen(app.get("port"), function() {
console.log("Express server listening on port " + app.get("port"));
});
and the api proj (uses Flask):
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=80)
UPDATE
I commented out the main line of my flask server and all 3 services are able to start. The downside is... now i dont have an api server. What is it about Flask that makes the other services unusable?
UPDATE 2
Some have requested to see the logs.
Here are the logs if i start without flask:
Building web
Step 1/10 : FROM node:8.9.3
---> 2eeae8debf3d
Step 2/10 : WORKDIR /app
---> Using cache
---> 02199a27dafb
Step 3/10 : COPY ./package.json /app
---> Using cache
---> fafac64ad492
Step 4/10 : COPY ./app.js /app
---> Using cache
---> 0b1e3067451b
Step 5/10 : COPY ./controllers /app/server
---> Using cache
---> ff00fa864078
Step 6/10 : COPY ./client /app/client
---> Using cache
---> 587214c84267
Step 7/10 : EXPOSE 3000
---> Using cache
---> ddd5b795fcf5
Step 8/10 : ENV PORT 3000
---> Using cache
---> ca4c37f63468
Step 9/10 : RUN npm install
---> Using cache
---> 74b289885447
Step 10/10 : ENTRYPOINT npm start
---> Using cache
---> 9c5ec6770c47
Successfully built 9c5ec6770c47
Successfully tagged testcomposemachine_web:latest
Recreating testcomposemachine_web_1
Starting testcomposemachine_db_1
Attaching to testcomposemachine_db_1, testcomposemachine_web_1
db_1 | 2017-12-28 23:11:55.861 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2017-12-28 23:11:55.861 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2017-12-28 23:11:55.874 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2017-12-28 23:11:55.907 UTC [24] LOG: database system was shut down at 2017-12-28 22:59:27 UTC
db_1 | 2017-12-28 23:11:55.919 UTC [1] LOG: database system is ready to accept connections
web_1 |
web_1 | > docker-web#1.0.0 start /app
web_1 | > node app.js
web_1 |
web_1 | Express Web server listening on port 3000
Here are the logs if i include flask:
Building api
Step 1/8 : FROM python:3.6
---> c1e459c00dc3
Step 2/8 : WORKDIR /api
---> Using cache
---> 8c9da963377c
Step 3/8 : COPY ./requirements.txt /api/requirements.txt
---> Using cache
---> 654c815801f6
Step 4/8 : COPY ./src /api/src
---> 5627279f7323
Removing intermediate container 453bf031c2f7
Step 5/8 : EXPOSE 80
---> Running in efb18f950f7d
---> 1389c63a0bcb
Removing intermediate container efb18f950f7d
Step 6/8 : ENV PORT 80
---> Running in 2ad88bed6343
---> fa85201cc165
Removing intermediate container 2ad88bed6343
Step 7/8 : RUN pip install -r requirements.txt
---> Running in e19107f5a449
Collecting flask==0.12.2 (from -r requirements.txt (line 1))
Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting itsdangerous>=0.21 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading itsdangerous-0.24.tar.gz (46kB)
Collecting Werkzeug>=0.7 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading Werkzeug-0.13-py2.py3-none-any.whl (311kB)
Collecting click>=2.0 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting Jinja2>=2.4 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask==0.12.2->-r requirements.txt (line 1))
Downloading MarkupSafe-1.0.tar.gz
Building wheels for collected packages: itsdangerous, MarkupSafe
Running setup.py bdist_wheel for itsdangerous: started
Running setup.py bdist_wheel for itsdangerous: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
Running setup.py bdist_wheel for MarkupSafe: started
Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built itsdangerous MarkupSafe
Installing collected packages: itsdangerous, Werkzeug, click, MarkupSafe, Jinja2, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.13 click-6.7 flask-0.12.2 itsdangerous-0.24
---> a7be838d3a6e
Removing intermediate container e19107f5a449
Step 8/8 : RUN python src/main.py
---> Running in e86c8adf46f0
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
Notice how when flask is included the other containers dont even build?
You have a RUN command that can not finish in your app dockerfile. This is preventing your dockerfile from ever finishing building. It's why it says step 8/8 and never says "successfully built" like your web container. I'd move that last run command into an entrypoint or CMD, like you have it in your web docker file, so that way the docker build command can actually finish.
IE CMD ["python", "src/main.py"] or ENTRYPOINT ["python", "src/main.py"]
That is most likely what is preventing your docker images from being built. Is because of that one last line in APP where you are starting a webserver in the foreground which never closes. Best bet is to place the command into entrypoint so it does not actually run during the build process, but will run when the image is started.
this is the line I'm talking about:
Step 8/8 : RUN python src/main.py
---> Running in e86c8adf46f0
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
VS this one out of the web build.
Step 10/10 : ENTRYPOINT npm start
---> Using cache
---> 9c5ec6770c47
Successfully built 9c5ec6770c47
Successfully tagged testcomposemachine_web:latest
Recreating testcomposemachine_web_1
Starting testcomposemachine_db_1
Attaching to testcomposemachine_db_1, testcomposemachine_web_1
the build will never finish if the command never completes. So yes, in a way the Flask API is preventing your docker-compose command from building all the other files.

Resources