Comments (10)
Yeah, oxker
should definitely correctly read and handle the $DOCKER_HOST
env.
As for the debug mode, again, yes it should force quit(?) if a docker connection cannot be achieved.
In the mean time, I think you should be able to use the DockerHub/ghcr image, but mount your custom socket instead of the default:
docker run --rm -it -v ~/.orbstack/run/docker.sock:/var/run/docker.sock:ro --pull=always mrjackwills/oxker
Although obviously this isn't a good long term solution.
Unfortunately I am away from my computer for at least another week, so I can't test, or implement, any fixes at the moment. Rust 1.71.0 has just been released, and I usually try to follow the same six week release schedule with oxker
.
from oxker.
I’ll need to come back to this in a couple of days, but I can try it from source.
from oxker.
I’ve done a bit more research, and I think that there’s an opportunity for a crate here to improve Docker context support across Rust projects. I suspect that there’s explicit code that could be translated from Go in the docker command-line itself, but here’s what I have seen:
- contexts are external to the Docker API, managed entirely in
~/.docker
. - the current context is found via
[~/.docker/config.json].currentContexst
- contexts themselves are defined in
~/.docker/contexts/meta/*/meta.json
; the directory betweenmeta/
andmeta.json
appears to be some sort of UUID-ish value (it might be a hashed value of the context name) - the contents of
meta.json
is incomplete compared todocker context inspect --format json CONTEXT
meta.json:
{
"Name": "orbstack",
"Metadata": {
"Description": "OrbStack"
},
"Endpoints": {
"docker": {
"Host": "unix:///Users/austin/.orbstack/run/docker.sock",
"SkipTLSVerify": false
}
}
}
docker context inspect --format json orbstack
[
{
"Name": "orbstack",
"Metadata": {
"Description": "OrbStack"
},
"Endpoints": {
"docker": {
"Host": "unix:///Users/austin/.orbstack/run/docker.sock",
"SkipTLSVerify": false
}
},
"TLSMaterial": {},
"Storage": {
"MetadataPath": "/Users/austin/.docker/contexts/meta/2d89b732b01a00a2d1675ed3cee9fd0f965daadf90603c989dd3afd4569c6896",
"TLSPath": "/Users/austin/.docker/contexts/tls/2d89b732b01a00a2d1675ed3cee9fd0f965daadf90603c989dd3afd4569c6896"
}
}
]
Ignoring the fact that docker context inspect --format json
returns an array, there are two additional keys TLSMaterial
(unknown contents, empty in my context) and Storage
(which is constructed from the discovered file paths themselves).
I’m not good enough with Rust to build such a crate, nor do I really have an interest in maintaining such a crate (my interest in Docker and related tools is as a user, not someone who wants to build tools for Docker), but this is what I have found.
from oxker.
The issue isn’t related to contexts, but is related to automatic resolution of $DOCKER_HOST
if it isn’t pointing to a Unix socket, if I’m reading it correctly. That said, bollard
is probably the right place to add this functionality, since it’s where connections are resolved.
If I were to weigh in on that, I would suggest:
Docker::connect_with_context_defaults()
- follows the Docker CLI behaviour ($DOCKER_HOST
overrides any context, checks thecurrentContext
value and resolves that if notdefault
, falls back toDocker::connect_with_socket_defaults()
otherwise)Docker::connect_with_context()
- parameterized context start, which I believe would ignore$DOCKER_HOST
, but I’m not sure.
Those could also be simplified as Docker::connect_with_defaults()
or Docker::connect()
, but I’m not sure that the creator of bollard
would want that, based on the comments there.
If you decide to implement this independently of bollard
, you would basically be getting the EndPoints.docker.Host
value and using Docker::connect_with_socket()
if it does not start with tcp://
and Docker::connect_with_ssl()
if it starts with tcp://
and SkipTLSVerify
is false
(the default).
from oxker.
@halostatue I've just pushed a branch fix/host, which I think should solve the issue. A new cli arg is available, --host
, to set the docker host path. However, it'll also check for a $DOCKER_HOST
env, at the moment the cli arg takes priority over the env - do you think this is the correct order?
Secondly, when in debug mode, it should exit with code 1 if there are any errors - amazed that this hasn't come up before and that I missed this.
If you are unable, or unwilling, to build from source, let me know and I can upload a binary here.
from oxker.
Sorry for the long delay, but the fix/host branch works when setting $DOCKER_HOST
. Ideally, oxker should work such that it can query the Docker contexts to find the current list and get the socket directly:
$ docker context ls --format '{{ . | json }}' | jq -s '.[] | select(.Current == true) | .DockerEndpoint'
"unix:///Users/austin/.orbstack/run/docker.sock"
But this can be considered closed because it now works with $DOCKER_HOST
.
from oxker.
@halostatue Thank you for taking the time to check that it works. I wasn't really aware of the Docker context before you submitted the issue. I should probably read the docs further to make sure I fully understand it, to make oxker
find the context automatically and correctly as you suggest.
One final note, did you manage to test the --host
cli arg, and if so did that work correctly?
Thanks again
from oxker.
It does:
$ oxker --host (docker context ls --format '{{ . | json }}' | jq -r -s '.[] | select(.Current == true) | .DockerEndpoint')
(I use fish, so that’s why the lack of $
.)
from oxker.
Perfect thanks, I'll merge the branch, and probably wait til rust 1.72.0 on August 24th before publishing a new version. Will do some testing about auto context finding that can be terminal agnostic.
from oxker.
Thank you, highly informative and helpful.
oxker
uses a crate called bollard to communicate with Docker. They actually have an open issue at the moment that I think might be related (I still haven't read enough into the Docker context, it's on my todo list) fussybeaver/bollard#310
from oxker.
Related Issues (20)
- [NEW FEATURE] Publish as Docker image HOT 6
- [BUG] Duplicate log entries
- Track `Cargo.lock` HOT 3
- [BUG] Heading bar loading icon color & position
- [NEW FEATURE] put container name next to Logs title
- [BUG] Malformed escape codes in docker logs causes panic HOT 5
- [NEW FEATURE] Sort columns reset
- [BUG] disable oxker commands
- [NEW FEATURE] Memory column spacing
- [NEW FEATURE] List Port HOT 2
- [BUG] created_at clash
- [NEW FEATURE] long term - detach logic
- [NEW FEATURE] Delete / Remove containers HOT 3
- [NEW FEATURE] Exec Shell - Open a container command line HOT 5
- [BUG] GHCR build issues HOT 1
- [NEW FEATURE] about column layout HOT 9
- [BUG] - Memory displayed incorrect HOT 3
- [BUG] issue freeze when click on CPU to show from high to low HOT 6
- [BUG] Double key strokes when trying to navigate on Windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oxker.