Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
20c189d7
Commit
20c189d7
authored
Aug 10, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12471 from peter-edge/docker-new-client-from-env
Use docker.NewClientFromEnv for creation of docker.Client
parents
cd3c3fe4
0458d707
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
docker.go
pkg/kubelet/dockertools/docker.go
+7
-13
No files found.
pkg/kubelet/dockertools/docker.go
View file @
20c189d7
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"fmt"
"fmt"
"math/rand"
"math/rand"
"net/http"
"net/http"
"os"
"path"
"path"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -283,19 +282,14 @@ func LogSymlink(containerLogsDir, podFullName, containerName, dockerId string) s
...
@@ -283,19 +282,14 @@ func LogSymlink(containerLogsDir, podFullName, containerName, dockerId string) s
return
path
.
Join
(
containerLogsDir
,
fmt
.
Sprintf
(
"%s_%s-%s.%s"
,
podFullName
,
containerName
,
dockerId
,
LogSuffix
))
return
path
.
Join
(
containerLogsDir
,
fmt
.
Sprintf
(
"%s_%s-%s.%s"
,
podFullName
,
containerName
,
dockerId
,
LogSuffix
))
}
}
// Get a
docker endpoint, either from the string passed in, or $DOCKER_HOST environment variables
// Get a
*docker.Client, either using the endpoint passed in, or using
func
getDockerEndpoint
(
dockerEndpoint
string
)
string
{
// DOCKER_HOST, DOCKER_TLS_VERIFY, and DOCKER_CERT path per their spec
var
endpoint
string
func
getDockerClient
(
dockerEndpoint
string
)
(
*
docker
.
Client
,
error
)
{
if
len
(
dockerEndpoint
)
>
0
{
if
len
(
dockerEndpoint
)
>
0
{
endpoint
=
dockerEndpoint
glog
.
Infof
(
"Connecting to docker on %s"
,
dockerEndpoint
)
}
else
if
len
(
os
.
Getenv
(
"DOCKER_HOST"
))
>
0
{
return
docker
.
NewClient
(
dockerEndpoint
)
endpoint
=
os
.
Getenv
(
"DOCKER_HOST"
)
}
else
{
endpoint
=
"unix:///var/run/docker.sock"
}
}
glog
.
Infof
(
"Connecting to docker on %s"
,
endpoint
)
return
docker
.
NewClientFromEnv
()
return
endpoint
}
}
func
ConnectToDockerOrDie
(
dockerEndpoint
string
)
DockerInterface
{
func
ConnectToDockerOrDie
(
dockerEndpoint
string
)
DockerInterface
{
...
@@ -304,7 +298,7 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {
...
@@ -304,7 +298,7 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {
VersionInfo
:
docker
.
Env
{
"ApiVersion=1.18"
},
VersionInfo
:
docker
.
Env
{
"ApiVersion=1.18"
},
}
}
}
}
client
,
err
:=
docker
.
NewClient
(
getDockerEndpoint
(
dockerEndpoint
)
)
client
,
err
:=
getDockerClient
(
dockerEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"Couldn't connect to docker: %v"
,
err
)
glog
.
Fatalf
(
"Couldn't connect to docker: %v"
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment