mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.57k stars 1.07k forks source link

Add any Shell to Docker Container #1593

Open RikuXan opened 1 year ago

RikuXan commented 1 year ago

Describe the feature request The MockServer Docker container seems to be barebones Java-only, without any type of shell (sh, ash, bash, zsh, etc.) in the container. Providing any of these shells within the container's path would help make the image more flexible in its usage.

What you are trying to do I'm trying to utilize MockServer within a GitLab pipeline as a service.
In order to load my config (and endpoint) file structure into the container, I am using a custom entrypoint that copies over these directories and then runs MockServer .
However, this currently fails due to no shell being provided within the container that could realize my custom entrypoint instructions.

The solution you'd like I think having a shell provided in the container would help not only with my use case, but in general when MockServer should be utilized in tasks where things need to be customizable beyond the provided configuration methods.

Describe alternatives you've considered I have tried using the snapshot Docker tag which seems to include a shell, but I would assume utilizing this tag for production purposes might not be the best idea (I'm assuming the shell is included in the snapshot tag for troubleshooting purposes and not because it is intended to be included in the upcoming version, otherwise my request is moot anyways).

myfunprograms commented 1 year ago

+1

I am using the mockserver/mockserver:mockserver-5.14.0 because I run my application using arms and amd hardware. On some Linux machine, I got Permission denied issue for the file I specified using MOCKSERVER_INITIALIZATION_JSON_PATH in the docker-compose file. I want to create a Dockerfile and change the permission explicitly. Without the support of any shell, there is no way to do it.

Like the previous thread mentioned, there could be a lot of cases that need to access the container using shell.

jocull commented 1 year ago

This seems to happen because it is on a distroless container: https://github.com/mock-server/mockserver/blob/b607ad690543b17a6f6d6ecd92292ca3f28afe0d/docker/Dockerfile#L38

I'd also like to see it changed to a different base because it makes debugging the server quite difficult. We have some cases running on M1 macOS (arm64 architecture) where the server seems to be hanging but we cannot figure out why. We've had to manually rebase mockserver onto a different image to diagnose. (No results so far)

jocull commented 1 year ago

Now that I am looking closer at the Dockerfile, a number of x86_64 natives are copied into the container, but the arm64 versions are seemingly absent. I expect that they are simply dropped when the arm64 version runs, falling back after the loading fails, but I wonder if they are causing a problem or process hang in some way that is difficult to detect?

The behavior we see is that the server simply stops responding, despite not logging anything new even at DEBUG level and the container is still running.