Reputation: 1698
How do I correctly configure and build my docker container/image to run on the web browser?
I have a meteor webapp, and using one of the existing base images: jshimko/meteor-launchpad, that comes recommended by the official Meteor Guide on Depolyment & Monitoring, tutorial found at meteor-launchpad-github. I have been able to build an image based on my web app, but its never assigned a port, therefore I am unable to run it in the browser.
Added the Dockerfile
to the root of my web app, and added the following contents
FROM debian:jessie
To build the image, I then run the below in the terminal
docker build -t sirbt/myapp .
Which yeilded:
Sending build context to Docker daemon 2.331MB
Step 1/1 : FROM debian:jessie
---> b6e9658de383
Successfully built b6e9658de383
Successfully tagged sirbt/myapp:latest
I then commence to saving the following contents in the .dockerignore
file that I also save in the app directory root
.git
.meteor/local
node_modules
and then run the code below to run myapp in the container
docker run -d \
-e ROOT_URL=http://example.com \
-e MONGO_URL=mongodb://url \
-e MONGO_OPLOG_URL=mongodb://oplog_url \
-e MAIL_URL=smtp://mail_url.com \
-p 70:3000 \
sirbt/myapp
the code then yeilds:
4e616999e521014fcb19d33869b45c79d93d6774d2d02e2f413343b72294f88b
I follow this by command:
docker ps
Which yeild:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
However
docker ps -a
yeilds:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4e616999e521 sirbt/myapp "bash" 3 minutes ago Exited (0) 2 minutes ago compassionate_greider
As you can tell, no port is assigned to the container to enable me to run it on the browser. The tutorial suggest that at this point I should be able to run it on the localhost on port 80 (in my case port 70). What am I missing here? How can I configure my docker container so that is assigned a port, enabling me to run it in the browser?
Find below the contents of my docker-compose.yml
# docker-compose.yml
app:
image: yourname/app
ports:
- "70:3000"
links:
- mongo
environment:
- ROOT_URL=http://example.com
- MONGO_URL=mongodb://mongo:27017/meteor
mongo:
image: mongo:latest
command: mongod --storageEngine=wiredTiger
Update to reflect why I am not using FROM jshimko/meteor-launchpad:latest
in my dockerfile
When I update my Dockerfile with FROM jshimko/meteor-launchpad:latest
as suggested in the tutorial. I get the following error message:
`Get:6 http://deb.debian.org jessie/main amd64 Packages [9098 kB]
Fetched 10.1 MB in 8s (1154 kB/s)
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease Unable to find expected entry 'main/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file)
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c cd $APP_SOURCE_DIR && $BUILD_SCRIPTS_DIR/install-deps.sh && $BUILD_SCRIPTS_DIR/install-node.sh && $BUILD_SCRIPTS_DIR/install-phantom.sh && $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh && $BUILD_SCRIPTS_DIR/install-mongo.sh && $BUILD_SCRIPTS_DIR/install-meteor.sh && $BUILD_SCRIPTS_DIR/build-meteor.sh && $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 100`
Upvotes: 1
Views: 1268
Reputation: 592
Make sure to read the meteor-launchpad tutorial closely, as it looks like you've missed a couple points.
I notice you said your Dockerfile is:
FROM debian:jessie
That's your main problem. It should be:
FROM jshimko/meteor-launchpad:latest
(or FROM jshimko/meteor-launchpad:some-specific-version
).
By changing the FROM
, you've made the rest of the tutorial irrelevant. You're now just building and running a basic Debian container that doesn't do anything.
Unfortunately, it looks like the meteor-launchpad
image is broken. It hasn't been updated in about 2 years, and it's built on an old version of Debian whose sources have been archived - that is the cause of your build error (see https://github.com/debuerreotype/docker-debian-artifacts/issues/66).
If you really want to use meteor-launchpad
, I'd recommend cloning its repo and building the image yourself.
git clone https://github.com/jshimko/meteor-launchpad.git
cd meteor-launchpad
docker build -t jshimko/meteor-launchpad:latest .
After doing that, you can probably follow the tutorial; however, you might need to change FROM debian:jessie
in the meteor-launchpad Dockerfile to use a more recent Debian version. This is not a production-worthy solution, but I'm recommending it since it sounds like you're just trying to get a learning project up and running.
I'd recommend reading up on Docker concepts, since the meteor-launchpad docs seem to assume you're pretty familiar with them. You could start with Docker's own tutorial docs.
Also, your docker-compose.yml
file is not being used. Docker Compose is an alternative to issuing docker run
commands directly; to use it, run the command docker-compose up [-d]
from the directory where the YML file is located. Using just the docker run
command you posted will start a container from the image you built, but it won't start a mongo container. You would have to start that separately.
Upvotes: 4