mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #6456 from rhatdan/tmpdir
Docker should use /var/lib/docker/tmp for large temporary files.
This commit is contained in:
commit
66c8f87e89
4 changed files with 37 additions and 5 deletions
|
@ -678,7 +678,10 @@ func NewDaemonFromDirectory(config *daemonconfig.Config, eng *engine.Engine) (*D
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up the TempDir to use a canonical path
|
// set up the TempDir to use a canonical path
|
||||||
tmp := os.TempDir()
|
tmp, err := utils.TempDir(config.Root)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to get the TempDir under %s: %s", config.Root, err)
|
||||||
|
}
|
||||||
realTmp, err := utils.ReadSymlinkedDirectory(tmp)
|
realTmp, err := utils.ReadSymlinkedDirectory(tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
|
log.Fatalf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
|
||||||
|
|
|
@ -120,12 +120,11 @@ systemd in the [docker source tree](
|
||||||
https://github.com/docker/docker/blob/master/contrib/init/systemd/socket-activation/).
|
https://github.com/docker/docker/blob/master/contrib/init/systemd/socket-activation/).
|
||||||
|
|
||||||
Docker supports softlinks for the Docker data directory
|
Docker supports softlinks for the Docker data directory
|
||||||
(`/var/lib/docker`) and for `/tmp`. TMPDIR and the data directory can be set
|
(`/var/lib/docker`) and for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be set like this:
|
||||||
like this:
|
|
||||||
|
|
||||||
TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
|
DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
|
||||||
# or
|
# or
|
||||||
export TMPDIR=/mnt/disk2/tmp
|
export DOCKER_TMPDIR=/mnt/disk2/tmp
|
||||||
/usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
|
/usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
|
||||||
|
|
||||||
## attach
|
## attach
|
||||||
|
|
12
utils/tmpdir.go
Normal file
12
utils/tmpdir.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TempDir returns the default directory to use for temporary files.
|
||||||
|
func TempDir(rootdir string) (string error) {
|
||||||
|
return os.TempDir(), nil
|
||||||
|
}
|
18
utils/tmpdir_unix.go
Normal file
18
utils/tmpdir_unix.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TempDir returns the default directory to use for temporary files.
|
||||||
|
func TempDir(rootDir string) (string, error) {
|
||||||
|
var tmpDir string
|
||||||
|
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
||||||
|
tmpDir = filepath.Join(rootDir, "tmp")
|
||||||
|
}
|
||||||
|
err := os.MkdirAll(tmpDir, 0700)
|
||||||
|
return tmpDir, err
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue