0

I have an application. The application is working on Linux, but I plan to migrate it to the docker container.

I developed some modules that can use embedded PostgreSQL instead of a regular Postgres database. It is working perfectly on my Host, but in the Docker, the process exits with code 1.

In the application, I want to start a subprocess with the following command:

cmd := exec.Command("embeded-postgres")

err := cmd.Run()

error is:

exit status 1

no other information in stderr or stdin

I think there is some mechanism that checks if only one process is working in the container, but I cannot find any documentation. Could anyone point me in to correct direction, please? I would like to read and understand more about this. Could anyone point

1 Answers1

1

If you could post your Dockerfile, it would really help determine the cause, I'd love to help you debug the issue further. Meanwhile, here are some things that might help you with the issue.

  1. You can have cmd.Run() output an actual error message to stderr
  2. To call exec.Command("embeded-postgres"), an executable named embeded-postgres needs to be located inside a directory in your $PATH, try using the full path where the executable is installed (for file, this would be /usr/bin/file). You can determine the path using which embeded-postgres
  3. Make sure the embeded-postgres executable is present in your container. Docker containers have a separate filesystem and while it shares some things with the host (like the kernel), if you have embeded-postgres installed on your host, the container won't be able to access it. Think of chroot but on steroids.
  4. While there isn't any mechanism that checks if only one process is running in the container, running multiple unrelated processes in a container is usually considered an anti-pattern.
  5. I don't have much information about your use case and I definitely don't know anything about embeded-postgres, but I found this Go library. Could this perhaps be a cleaner solution instead of installing a system executable and calling it with os/exec?
GNUPepe
  • 56
  • 2