selenoid
selenoid copied to clipboard
Add ability to set docker user and command/entrypoint
This adds support for user
, cmd
and entrypoint
attributes, which can be set in the browsers.json
config, and overridable using capabilities. If not set, the behavior remains unchanged: it's still going to use the USER
and the CMD
/ ENTRYPOINT
instruction set in the docker image.
This is useful to be able to use an alternative entrypoint at container startup, which may need to run administrative tasks in the container.
My current use-case for this is that I'm using an IPv6-enabled docker network, and in some tests I want to be able to run IPv6-only connectivity. To achieve that, I'm running a custom entrypoint before calling the existing /entrypoint.sh
, which simply delete the IPv4 default route to break external IPv4 connectivity, based on an environment variable set from the capabilities.
# if IPv6 only is requested, delete the default IPv4 route to nuke IPv4 external connectivity
if [ "$(echo ${IPV6_ONLY:-} | tr '[A-Z]' '[a-z]')" = "true" ]; then
ip -4 route del default || true
fi
exec /entrypoint.sh
I'm also thinking about creating a PR in https://github.com/aerokube/images/ to add support for pre/post hooks in the existing entrypoint.sh
. So I could use --volume /path/to/my/script:/entrypoint.pre.d/10-kill-ipv4:ro
when starting the browser containers, but I'll still need to be able to run the container as root.
Marking as draft for now as coverage tests will probably fail.
Added coverage for tests
@lionelnicolas shouldn't this be implemented as custom Docker images instead?
Codecov Report
Merging #1238 (5ac944a) into master (8a0f80a) will increase coverage by
0.36%
. The diff coverage is100.00%
.
:exclamation: Current head 5ac944a differs from pull request most recent head f32d7fa. Consider uploading reports for the commit f32d7fa to get more accurate results
@@ Coverage Diff @@
## master #1238 +/- ##
==========================================
+ Coverage 76.27% 76.63% +0.36%
==========================================
Files 12 12
Lines 1437 1451 +14
==========================================
+ Hits 1096 1112 +16
+ Misses 260 258 -2
Partials 81 81
Flag | Coverage Δ | |
---|---|---|
go | 76.63% <100.00%> (+0.36%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
config/config.go | 97.22% <ø> (ø) |
|
session/session.go | 92.59% <ø> (ø) |
|
service/docker.go | 75.27% <100.00%> (+1.07%) |
:arrow_up: |
service/service.go | 71.11% <0.00%> (ø) |
|
selenoid.go | 87.50% <0.00%> (+0.37%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update fbf82d8...f32d7fa. Read the comment docs.
Yeah I thought about that too, but I wanted to be able to use upstream selenoid images to avoid having to manage custom images.
@vania-pooh What do you think about this PR ? I think this is something that could be useful to some people. If you agree with that patch maybe I should update the documentation too.
Otherwise, feel free to close the PR, and then I'll handle custom docker images on my side.
Let's not overcomplicate things.