I need to publish a Dockerfile that contains https://aerokube.com/selenoid.
This has to be a Dockerfile so I can publish it to our container registry which will be used as a service container as part of the pipeline/text execution https://learn.microsoft.com/en-us/azure/devops/pipelines/process/service-containers?view=azure-devops&tabs=yaml
Here is my dockerfile
FROM alpine:3.14
# Update Package
RUN apk update
# Install Selenoid Configuration Manager
RUN wget -O /usr/bin/cm https://github.com/aerokube/cm/releases/download/1.8.5/cm_linux_amd64
&& chmod +x /usr/bin/cm
# create dir
RUN mkdir -p /etc/selenoid
# Copy browsers.json
COPY browsers.json /etc/selenoid/browsers.json
EXPOSE 4444
CMD["/usr/bin/cm", "-conf", "/etc/selenoid/browsers.json"]
My browsers.json file is located in the same directory as the Dockerfile.
In my local testing I get the following error when trying to run the container
Error: unknown command "/etc/selenoid/browsers.json" for "cm"
Run 'cm --help' for usage.
I have also tried updating the command to be
CMD ["/usr/bin/cm", "selenoid","start", "-conf", "/etc/selenoid/browsers.json"]
But the error is even more insane
Failed to initialize: [can not access Docker: make sure you have Docker installed and current user has access permissions]
Changing CMD to ENTRYPOINT is the same result
2
Answers
Not sure if it’s misspelled but you has space missing in original dockerfile.
Should be:
The error
unknown command "/etc/selenoid/browsers.json" for "cm"
suggests there is an issue with the command syntax in the Dockerfile. The command parameters are not being recognized correctly.Make sure the CMD instruction is properly formatted as a JSON array.
And the error message
can not access Docker: make sure you have Docker installed and current user has access permissions
indicates that the Selenoid service is unable to access Docker.Try and mount the Docker socket inside your container. That can be done by adding a volume mount when running the Docker container.
Finally, using
ENTRYPOINT
instead ofCMD
is advisable when you want your container to run as an executable.Your revised Dockerfile would be: