Deploying existing container, as-is, without modification?

If I want to deploy an existing container, for which the image exists in a public registry, to a device, what is the right way to do that?

Some experimentation suggests that I can make a trivial Dockerfile wrapper than just uses:
FROM: myregistry.io/image:latest

and do the expected balena push my_application. Is that a wrong/bad way of doing it?

As a follow-up to that, and this might be more of a Docker question than a Balena question:
How can I map some regular command line docker run options to the container that I am pushing out to devices?

It looks like env variables I can do either in the dashboard or with ENV FOO=fooval inside the dockerfile, if I use the “trivial wrapper” technique above.

But publishing ports, easy with docker cli, e.g. --publish 1680:1680/udp, I am not sure how to do.
It looks like EXPOSE doesn’t actually do anything?

The one forum answer I found was to make this configuration in a docker-compose.yml file; is it the case that I will need to “compose” even for a single container, if I want to get the ports set up for my device in the same way as I could get with the CLI invocation of --publish 1680:1680/udp ?

I want to accomplish a similar mapping for CLI options like --restart always, --mount type=bind,source....… I am still reading through the Dockerfile reference (I’m new to actually building containers, always have just “run” them as needsbe) to see if there’s an answer there.

But the same question as above applies: for some expected set of CLI options, should I create a specialization as a Dockerfile or docker-compose wrapped around the existing container?

Hello Andrew,
Welcome to the forums! Your “trivial” Dockerfile wrapper example is not a “bad way” to go and may be all you need depending on your requirements. (In your example, you would still need to add at least a CMD [ "sleep", "infinity" ] line to the file to keep it from constantly restarting.) As you suspected, you can deploy a single container using either a Dockerfile or a docker-compose.yml file. If you want to map ports to the host network, you have to use docker-compose. (There’s a good tutorial on that here: https://www.balena.io/docs/learn/more/masterclasses/services-masterclass/#4-networking-types)
The other options you mentioned, such as restart always is also something you’d want to do in a docker-compose file. Defining an image in docker-compose uses the format image: myregistry.io/image:latest
Sometimes, you’ll want to use a combination of docker-compose and dockerfiles, for instance when you want to start with a prebuilt image and then extend it with more functionality. Through docker-compose you can specify one or more Dockerfiles to be built and run.
There’s more details about docker-compose in the link above, as well as on this page: https://www.balena.io/docs/learn/develop/multicontainer/
Good luck on your exploration with containers and feel free to post any further questions here!

1 Like

OK, perf. It sounds like learning docker-compose is a definite “need” here and will be the lingua franca for steering containers into being what I want them to be.

Time to learn another whole technology stack :sweat_smile::sweat_smile::sweat_smile: