When I do sbt docker:publishLocal, it creates a Dockerfile automatically erasing previous content of the file.
I wanted to add custom commands to add cassandra to the container. I copy pasted the content of this file
and tried to run above command again. But that wipes out all existing content and replace it with default content.
How can I add docker commands in Dockerfile or build.sbt?
The sbt-docker plugin has a customization section, including one "Write from Scratch", which could be of interest:
You can simply wipe out all docker commands with
dockerCommands := Seq()
Now let’s start adding some Docker commands.
import com.typesafe.sbt.packager.docker._
dockerCommands := Seq(
Cmd("FROM", "openjdk:8"),
Cmd("LABEL", s"""MAINTAINER="${maintainer.value}""""),
ExecCmd("CMD", "echo", "Hello, World from Docker")
)
You can write your custom Dockerfile that way: it will be correctly regenerated.
How am I going to add something like this:
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
&& wget -O /usr/local/bin/gosu....
As in the example from the documentation:
ExecCmd("RUN",
"set", "-x",
"&&",
"apt-get", "update", ...
),