I’d like to create a docker container that can read file named helloworld.proto and run command
protoc --dart_out=grpc:lib/src/generated -Iprotos protos/helloworld.proto
The container would start with all the dependencies and generate required file using gRPC which is accessible by the HOST machine. Is this achievable?
If the primary goal of your process is to read a file from the host system and write a file back to the host system, you will find it much easier to run the process directly on the host system and not involve Docker.
You can in principle use Docker bind mounts to make a host directory visible to the container. Especially for a one-off command, though, the length of the command line required to start the container will be longer than the length of the command you’re trying to run:
sudo \ # docker run can take over the host so root is required
docker run \
--rm \ # delete the container when done
-v "$PWD:/data" \ # make host directive visible to container
-w /data \ # make mounted directory current working directory
-u $(id -u):$(id -g) \ # write files as current host user
proton --dart-out=grpc:lib/src/generated -Iprotos protos/helloworld.proto
It will usually be a single command (
sudo apt-get install protobuf-compiler,
brew install protobuf) to get
protoc installed globally on your host system and that will usually be easier to manage.
Answered By – David Maze
Answer Checked By – Willingham (FlutterFixes Volunteer)