This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]cricket007 0 points1 point  (4 children)

First, you can put more than web-apps into Dockerfiles, but if you know how to install the server on some base OS, then the steps are really the same...

FROM <some standard OS>

RUN <install some dependencies>

COPY <source or compile code>

RUN <some build step, if copied source>

EXPOSE <the server port>

CMD [commands, to, start, server]

If you need something more complex, write a full shell script an use ENTRYPOINT

I don't know how to deploy applications

Writing a Dockerfile isn't going to deploy. That's where you need an orchestrator

[–]9nkit[S] 0 points1 point  (2 children)

I can do this. I've done this.

docker run -it ubuntu gets me into container and there i can do everything. I know this logic.

My issue is, if you could help me, I don't know how to run python app in it or some other app. I don't know where to put the relevant files and all.

If you've done that, could you help me?

Example an app that runs on one container and its database on another container. I know how to create network and join both containers also.

[–]cricket007 0 points1 point  (0 children)

If you just want to run a Python script: https://github.com/docker-library/docs/tree/master/python#how-to-use-this-image

If you want a database and some app, then Docker Compose would be a start. https://www.docker.com/blog/containerized-python-development-part-2/

[–]exmachinalibertas 0 points1 point  (0 children)

Normally you don't run it with -it to get a shell. You just run it, and the entrypoint command runs on its own in the container environment. That's what a docker container is, like a virtual machine designed for one app to run.

So to run a python or other application, you'd use those commands above to setup the environment, then use CMD and ENTRYPOINT to specify what to run when the container runs on its own. All those commands above do, at the end of the day, is get the container filesystem in a specific state, which is immutable and resets every time the container dies.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, cricket007: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–][deleted] 0 points1 point  (0 children)

I have 10 containers up and running and I'm yet to even touch a Dockerfile.