├── .eslintrc
├── .gitignore
├── .gitmodules
├── .markdownlint.json
├── Jenkinsfile
├── LICENSE
├── Makefile
├── README.md
├── bin
├── .service
└── sdc-dockeradm
├── boot
├── configure.sh
└── setup.sh
├── docs
├── README.md
├── api
│ ├── README.md
│ ├── commands
│ │ ├── NOTICE.md
│ │ ├── attach.md
│ │ ├── build.md
│ │ ├── commit.md
│ │ ├── cp.md
│ │ ├── create.md
│ │ ├── diff.md
│ │ ├── events.md
│ │ ├── exec.md
│ │ ├── export.md
│ │ ├── history.md
│ │ ├── images.md
│ │ ├── import.md
│ │ ├── info.md
│ │ ├── inspect.md
│ │ ├── kill.md
│ │ ├── load.md
│ │ ├── login.md
│ │ ├── logout.md
│ │ ├── logs.md
│ │ ├── pause.md
│ │ ├── port.md
│ │ ├── ps.md
│ │ ├── pull.md
│ │ ├── push.md
│ │ ├── rename.md
│ │ ├── restart.md
│ │ ├── rm.md
│ │ ├── rmi.md
│ │ ├── run.md
│ │ ├── save.md
│ │ ├── search.md
│ │ ├── start.md
│ │ ├── stats.md
│ │ ├── stop.md
│ │ ├── tag.md
│ │ ├── top.md
│ │ ├── unpause.md
│ │ ├── version.md
│ │ └── wait.md
│ ├── divergence.md
│ ├── features
│ │ ├── logdrivers.md
│ │ ├── networks.md
│ │ ├── placement.md
│ │ ├── repos.md
│ │ ├── resources.md
│ │ ├── restart.md
│ │ ├── security.md
│ │ ├── smartos.md
│ │ └── volumes.md
│ └── troubleshooting.md
├── development
│ ├── docker-issues.md
│ ├── images.md
│ ├── usage-examples.md
│ ├── use-case-Dev1.md
│ ├── use-case-Dev2.md
│ ├── use-case-Ops1.md
│ └── use-case-personas.md
├── guide
│ └── README.md
└── link-patterns.txt
├── etc
├── scratch_image.json
├── scratch_image.manifest
└── scratch_image.tar
├── lib
├── audit-logger.js
├── auth.js
├── backends
│ ├── lxzone
│ │ ├── containers.js
│ │ ├── imgadm.js
│ │ ├── index.js
│ │ └── sysinfo.js
│ └── sdc
│ │ ├── affinity.js
│ │ ├── build.js
│ │ ├── containers.js
│ │ ├── images.js
│ │ ├── index.js
│ │ ├── networks.js
│ │ ├── sysinfo.js
│ │ ├── utils.js
│ │ └── volumes.js
├── common.js
├── config-loader.js
├── connwatcher.js
├── constants.js
├── containers.js
├── docker.js
├── endpoints
│ ├── _ping.js
│ ├── admin
│ │ ├── config.js
│ │ ├── image-tags-v2.js
│ │ ├── images-v2.js
│ │ ├── index.js
│ │ └── progress.js
│ ├── auth.js
│ ├── build.js
│ ├── ca.js
│ ├── commit.js
│ ├── containers.js
│ ├── events.js
│ ├── exec.js
│ ├── images.js
│ ├── index.js
│ ├── info.js
│ ├── networks.js
│ ├── version.js
│ └── volumes.js
├── errors.js
├── hijack.js
├── models
│ ├── image-tag-v2.js
│ ├── image-tag.js
│ ├── image-v2.js
│ ├── image.js
│ ├── index.js
│ └── link.js
├── moray.js
├── plugin-manager.js
├── socket-manager.js
├── units.js
├── validate.js
├── volumes.js
└── wfapi
│ ├── index.js
│ └── workflows
│ ├── pull-image-v2.js
│ └── push-image.js
├── package.json
├── plugins
├── filter_owner_networks.js
└── provision_limits.js
├── sapi_manifests
└── docker
│ ├── manifest.json
│ └── template
├── smf
├── manifests
│ └── docker.xml.in
└── method
│ └── docker
├── test
├── README.md
├── compose
│ └── compose-with-nfs-volume
│ │ └── docker-compose.yml
├── images
│ ├── README.md
│ ├── test-image-with-volume
│ │ ├── Dockerfile
│ │ └── Makefile
│ └── test-nginx
│ │ ├── Dockerfile
│ │ ├── Makefile
│ │ └── README.md
├── integration
│ ├── api-admin-config.test.js
│ ├── api-build.test.js
│ ├── api-create-invalid-names.test.js
│ ├── api-create-with-volume-from-image.test.js
│ ├── api-create.test.js
│ ├── api-images-v1-v2.test.js
│ ├── api-images.test.js
│ ├── api-info.test.js
│ ├── api-invalid.test.js
│ ├── api-mount-nfs-shared-volume-as-docker-compose.test.js
│ ├── api-mounts-nfs-shared-volume-networks.test.js
│ ├── api-network.test.js
│ ├── api-rename-used-nfs-shared-volume.test.js
│ ├── api-start-stop.test.js
│ ├── apiversion.test.js
│ ├── cli-affinity.test.js
│ ├── cli-attach.test.js
│ ├── cli-commit.test.js
│ ├── cli-copy.test.js
│ ├── cli-filters.test.js
│ ├── cli-image-rmi.test.js
│ ├── cli-image-tag.test.js
│ ├── cli-info.test.js
│ ├── cli-labels.test.js
│ ├── cli-links.test.js
│ ├── cli-local-volumes.test.js
│ ├── cli-mount-nfs-volume-created-with-docker-create.test.js
│ ├── cli-nfs-shared-volumes-create-duplicate-name.test.js
│ ├── cli-nfs-shared-volumes-create-failure.test.js
│ ├── cli-nfs-shared-volumes-create-size.test.js
│ ├── cli-nfs-shared-volumes-delete-in-use.test.js
│ ├── cli-nfs-shared-volumes-disabled.test.js
│ ├── cli-nfs-shared-volumes-docker-880.test.js
│ ├── cli-nfs-shared-volumes-filter-dangling.test.js
│ ├── cli-nfs-shared-volumes-mount-overrides-local-volume.test.js
│ ├── cli-nfs-shared-volumes-mounting-mode.test.js
│ ├── cli-nfs-shared-volumes-networks.test.js
│ ├── cli-nfs-shared-volumes.test.js
│ ├── cli-packagelabels.test.js
│ ├── cli-pull.test.js
│ ├── cli-push.test.js
│ ├── cli-run-add-host.test.js
│ ├── cli-run-ports.test.js
│ ├── cli-search.test.js
│ ├── cli-triton-tags.test.js
│ ├── compose-with-nfs-volume.test.js
│ ├── foo.test.js.in
│ ├── helpers.js
│ └── sdcdockertest_client.user-script.in
├── lib
│ ├── cli.js
│ ├── common.js
│ ├── compose-cli.js
│ ├── log.js
│ ├── vm.js
│ ├── volumes-api.js
│ ├── volumes-cli.js
│ └── volumes.js
├── runtest
├── runtest.common
├── runtests
└── unit
│ ├── affinity.test.js
│ ├── common.test.js
│ ├── get-vm-in-state.test.js
│ ├── plugin-filter-owner-networks.test.js
│ ├── plugin-provision-limits.test.js
│ └── ports.test.js
├── tls
├── ca-key.pem
├── ca.pem
├── ca.srl
├── cert.pem
├── extfile.cnf
├── key.pem
├── server-cert.pem
└── server-key.pem
└── tools
├── check-docs.sh
├── console.js
├── docker-client-env
├── gen_packages.js
├── get-compose-clients.sh
├── get-docker-clients.sh
├── install-docker.js.sh
├── jsl.node.conf
├── jsstyle.conf
├── md5sum-for-smartos-gz
├── mk-shar
├── pre-commit.sh
├── rsync-to
└── sdc-docker-setup.sh
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [ "joyent" ],
3 | "extends": [
4 | "eslint:recommended",
5 | "plugin:joyent/style",
6 | "plugin:joyent/lint"
7 | ],
8 | "parserOptions": {
9 | "ecmaVersion": 6,
10 | "sourceType": "script",
11 | "ecmaFeatures": {
12 | }
13 | },
14 | "env": {
15 | "node": true,
16 | "es6": true
17 | },
18 | "rules": {
19 | // Local rule configuration
20 | "no-unused-vars": [
21 | "error",
22 | {
23 | // Track all unused identifiers
24 | "vars": "all",
25 | "args": "all",
26 | "caughtErrors": "all",
27 | // Don't warn on args that start with _, res or req.
28 | // Added stdout and stderr to the standard joyent set.
29 | "argsIgnorePattern": "^(_|res|req|stdout|stderr)",
30 | // Don't warn on catch or var identifiers that start with _
31 | "caughtIgnorePattern": "^_",
32 | "varsIgnorePattern": "^(_|res|req|stdout|stderr)"
33 | }
34 | ],
35 | "max-len": [
36 | "error",
37 | 80,
38 | {
39 | "tabWidth": 8,
40 | "ignoreComments": false,
41 | "ignoreTrailingComments": false,
42 | "ignoreUrls": true
43 | }
44 | ],
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /make_stamps
2 | /node_modules
3 | /tmp
4 | /bits
5 | /build
6 | /smf/manifests/docker.xml
7 | .*.swp
8 | /docker-pkg*.tar.gz
9 | /docs/*.html
10 | /docs/*.json
11 | .DS_Store
12 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "deps/jsstyle"]
2 | path = deps/jsstyle
3 | url = https://github.com/TritonDataCenter/jsstyle.git
4 | [submodule "deps/sdc-scripts"]
5 | path = deps/sdc-scripts
6 | url = https://github.com/TritonDataCenter/sdc-scripts.git
7 | [submodule "deps/restdown"]
8 | path = deps/restdown
9 | url = https://github.com/TritonDataCenter/restdown.git
10 | [submodule "deps/restdown-brand-remora"]
11 | path = deps/restdown-brand-remora
12 | url = https://github.com/TritonDataCenter/restdown-brand-remora.git
13 | [submodule "deps/eng"]
14 | path = deps/eng
15 | url = https://github.com/TritonDataCenter/eng.git
16 |
--------------------------------------------------------------------------------
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "commands-show-output": false,
3 | "line-length": false,
4 | "single-h1": false
5 | }
6 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright 2022 Joyent, Inc.
9 | * Copyright 2025 MNX Cloud, Inc.
10 | */
11 |
12 | @Library('jenkins-joylib@v1.0.8') _
13 |
14 | pipeline {
15 |
16 | agent {
17 | label joyCommonLabels(image_ver: '21.4.0', pi:'20210826T002459Z')
18 | }
19 |
20 | options {
21 | buildDiscarder(logRotator(numToKeepStr: '30'))
22 | timestamps()
23 | }
24 |
25 | parameters {
26 | string(
27 | name: 'AGENT_PREBUILT_AGENT_BRANCH',
28 | defaultValue: '',
29 | description: 'The branch to use for the agents ' +
30 | 'that are included in this component.
' +
31 | 'With an empty value, the build will look for ' +
32 | 'agents from the same branch name as the ' +
33 | 'component, before falling back to "master".'
34 | )
35 | }
36 |
37 | stages {
38 | stage('check') {
39 | steps{
40 | sh('make check')
41 | }
42 | }
43 | // avoid bundling devDependencies
44 | stage('re-clean') {
45 | steps {
46 | sh('git clean -fdx')
47 | }
48 | }
49 | stage('build image and upload') {
50 | steps {
51 | joyBuildImageAndUpload()
52 | }
53 | }
54 | }
55 |
56 | post {
57 | always {
58 | joySlackNotifications()
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/bin/.service:
--------------------------------------------------------------------------------
1 | export SVC=docker
2 |
--------------------------------------------------------------------------------
/bin/sdc-dockeradm:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2015, Joyent, Inc.
10 | #
11 |
12 | LOGLINES=50
13 | PWD=$(unset CDPATH; cd $(dirname $0); pwd)
14 | TOP=$(unset CDPATH; cd $PWD/..; pwd)
15 | BUNYAN=${TOP}/node_modules/.bin/bunyan
16 | SVC_FILE=$PWD/.service
17 |
18 | function fatal()
19 | {
20 | echo "Error: $*" >&2
21 | exit 1
22 | }
23 |
24 |
25 |
26 | # --- Load service variable and any other variables that depend on it
27 |
28 |
29 |
30 | [[ ! -e $SVC_FILE ]] && fatal "Service file \"$SVC_FILE\" does not exist"
31 | source $SVC_FILE
32 | [[ -z $SVC ]] && fatal "SVC variable not exported in service file \"$SVC_FILE\""
33 |
34 | LOGFILE=$(svcs -L ${SVC})
35 |
36 |
37 |
38 | function restart_svc()
39 | {
40 | local state
41 | state=$(svcs -o state -H ${SVC})
42 |
43 | case "$state" in
44 | "disabled")
45 | exec svcadm enable ${SVC}
46 | ;;
47 | "maintenance")
48 | exec svcadm clear ${SVC}
49 | ;;
50 | *)
51 | exec svcadm restart ${SVC}
52 | ;;
53 | esac
54 | }
55 |
56 |
57 | function usage()
58 | {
59 | local msg me
60 | msg="$*"
61 | [[ -n "$msg" ]] && echo "$msg"
62 | me=$(basename $0)
63 | cat - >&2 <
68 |
69 | Subcommands:
70 | grep Grep the current and historical service logs for a string
71 | lastlog View the last ${LOGLINES} bunyan-formatted log lines
72 | log View the bunyan-formated log
73 | restart Restart the service
74 | stop Stop the service
75 | tail Tail the log and pipe through bunyan
76 | USAGE
77 | exit 2
78 | }
79 |
80 |
81 |
82 | # --- Mainline
83 |
84 |
85 |
86 | CMD=$1
87 |
88 | case "$CMD" in
89 | "clear")
90 | exec svcadm clear ${SVC}
91 | ;;
92 | "log")
93 | ${BUNYAN} ${LOGFILE}
94 | ;;
95 | "lastlog")
96 | # XXX: allow overriding LOGLINES with an opt
97 | exec tail -n ${LOGLINES} ${LOGFILE} | ${BUNYAN}
98 | ;;
99 | "grep")
100 | [[ -z $2 ]] && usage "Must specify string to search for!"
101 | grep -h $2 ${LOGFILE} /var/log/sdc/upload/*${SVC}* | ${BUNYAN}
102 | ;;
103 | "restart")
104 | restart_svc
105 | ;;
106 | "stop")
107 | svcadm disable ${SVC}
108 | ;;
109 | "tail")
110 | exec tail -f ${LOGFILE} | ${BUNYAN}
111 | ;;
112 | "")
113 | usage
114 | ;;
115 | *)
116 | fatal "Unknown command \"$CMD\""
117 | ;;
118 | esac
119 |
--------------------------------------------------------------------------------
/boot/configure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 | # -*- mode: shell-script; fill-column: 80; -*-
3 | #
4 | # This Source Code Form is subject to the terms of the Mozilla Public
5 | # License, v. 2.0. If a copy of the MPL was not distributed with this
6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | #
8 |
9 | #
10 | # Copyright (c) 2014, Joyent, Inc.
11 | #
12 |
13 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
14 | set -o xtrace
15 | set -o errexit
16 | set -o pipefail
17 |
18 | PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
19 |
20 | exit 0
21 |
--------------------------------------------------------------------------------
/boot/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 | # -*- mode: shell-script; fill-column: 80; -*-
3 | #
4 | # This Source Code Form is subject to the terms of the Mozilla Public
5 | # License, v. 2.0. If a copy of the MPL was not distributed with this
6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | #
8 |
9 | #
10 | # Copyright (c) 2014, Joyent, Inc.
11 | #
12 |
13 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
14 | set -o xtrace
15 | set -o errexit
16 |
17 | DEFAULT_HOSTNAME="*.triton"
18 | PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
19 | role=docker
20 |
21 | function setup_tls_certificate() {
22 | if [[ -f /data/tls/key.pem && -f /data/tls/cert.pem ]]; then
23 | echo "TLS Certificate Exists"
24 | else
25 | echo "Generating TLS Certificate"
26 | mkdir -p /data/tls
27 | /opt/local/bin/openssl req -x509 -nodes -subj "/CN=$DEFAULT_HOSTNAME" \
28 | -newkey rsa:2048 -keyout /data/tls/key.pem \
29 | -out /data/tls/cert.pem -days 365
30 | # Remember the certificate's host name used in the cert.
31 | echo "$HOST" > /data/tls/hostname
32 | fi
33 | }
34 |
35 | # Include common utility functions (then run the boilerplate)
36 | source /opt/smartdc/boot/lib/util.sh
37 | CONFIG_AGENT_LOCAL_MANIFESTS_DIRS=/opt/smartdc/$role
38 | sdc_common_setup
39 |
40 | # Mount our delegate dataset at '/data'.
41 | zfs set mountpoint=/data zones/$(zonename)/data
42 |
43 | setup_tls_certificate
44 |
45 | /usr/sbin/svccfg import /opt/smartdc/$role/smf/manifests/docker.xml
46 |
47 | # Add build/node/bin and node_modules/.bin to PATH
48 | echo "" >>/root/.profile
49 | echo "export PATH=\$PATH:/opt/smartdc/$role/build/node/bin:/opt/smartdc/$role/node_modules/.bin:/opt/smartdc/$role/bin" >>/root/.profile
50 |
51 | # Log rotation.
52 | sdc_log_rotation_add amon-agent /var/svc/log/*amon-agent*.log 1g
53 | sdc_log_rotation_add config-agent /var/svc/log/*config-agent*.log 1g
54 | sdc_log_rotation_add registrar /var/svc/log/*registrar*.log 1g
55 | sdc_log_rotation_add $role /var/svc/log/*$role*.log 1g
56 | sdc_log_rotation_setup_end
57 |
58 | # All done, run boilerplate end-of-setup
59 | sdc_setup_complete
60 |
61 | exit 0
62 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # SDC Docker User Guide
2 |
3 | The SDC Docker [User Guide](api/README.md) provides the information on how to connect to the Docker Remote API,
4 | its [methods](api/commands), and [features](api/features).
5 |
6 | The SDC Docker implementation does have some differences from Docker Inc.'s implementation. Note the
7 | [divergence](api/divergence.md) before you start using SDC Docker.
8 |
9 | # Developer Guide
10 |
11 | Get started with contributing to this open source project by reading about the installation and administration
12 | of SDC Docker from the repo [README](../README.md).
13 |
14 | # Docker Basics
15 |
16 | If you are new to Docker, you may want to read the [Docker User Guide](https://docs.docker.com/engine/userguide/)
17 | to understand some of the basic concepts first.
18 |
--------------------------------------------------------------------------------
/docs/api/commands/NOTICE.md:
--------------------------------------------------------------------------------
1 | sdc-docker is subject to the terms of the Mozilla Public License,
2 | v. 2.0. If a copy of the MPL was not distributed with this file,
3 | You can obtain one at http://mozilla.org/MPL/2.0/.
4 |
5 | The sdc-docker API method and CLI command documentation includes content
6 | written by third parties. The following third party content is included,
7 | and carry their own copyright notices and license terms:
8 |
9 | * The documentation for API methods and CLI commands includes content
10 | from or derived from content copyrighted by Docker, Inc. and
11 | developed by Docker, Inc. and contributors. That content is found
12 | in docs/api/commands/ within this distribution. Content there is
13 | redistributed under the terms of the Apache 2.0 license as noted in
14 | the source repo (https://github.com/docker/docker):
15 |
16 | Copyright 2013-2015 Docker, Inc.
17 |
18 | Licensed under the Apache License, Version 2.0 (the "License");
19 | you may not use this file except in compliance with the License.
20 | You may obtain a copy of the License at
21 |
22 | https://www.apache.org/licenses/LICENSE-2.0
23 |
24 | You may reproduce and distribute copies of the
25 | Work or Derivative Works thereof in any medium, with or without
26 | modifications, and in Source or Object form, provided that You
27 | meet the following conditions:
28 |
29 | (a) You must give any other recipients of the Work or
30 | Derivative Works a copy of this License; and
31 |
32 | (b) You must cause any modified files to carry prominent notices
33 | stating that You changed the files; and
34 |
35 | (c) You must retain, in the Source form of any Derivative Works
36 | that You distribute, all copyright, patent, trademark, and
37 | attribution notices from the Source form of the Work,
38 | excluding those notices that do not pertain to any part of
39 | the Derivative Works; and
40 |
41 | (d) If the Work includes a "NOTICE" text file as part of its
42 | distribution, then any Derivative Works that You distribute must
43 | include a readable copy of the attribution notices contained
44 | within such NOTICE file, excluding those notices that do not
45 | pertain to any part of the Derivative Works, in at least one
46 | of the following places: within a NOTICE text file distributed
47 | as part of the Derivative Works; within the Source form or
48 | documentation, if provided along with the Derivative Works; or,
49 | within a display generated by the Derivative Works, if and
50 | wherever such third-party notices normally appear. The contents
51 | of the NOTICE file are for informational purposes only and
52 | do not modify the License. You may add Your own attribution
53 | notices within Derivative Works that You distribute, alongside
54 | or as an addendum to the NOTICE text from the Work, provided
55 | that such additional attribution notices cannot be construed
56 | as modifying the License.
57 |
58 |
59 | * Additional copyright may be retained by contributors other
60 | than Joyent, the sdc-docker developers, or the parties
61 | enumerated in this file. Such copyright can be determined
62 | on a case-by-case basis by examining the author of each
63 | portion of a file in the revision-control commit records
64 | of the project, or by consulting representative comments
65 | claiming copyright ownership for a file.
66 |
67 | In all such cases, the absence of explicit licensing text
68 | indicates that the contributor chose to license their work
69 | for distribution under identical terms to those Joyent
70 | has chosen for the collective work, enumerated at the top
71 | of this file. The only difference is the retention of
72 | copyright itself, held by the contributor.
73 |
--------------------------------------------------------------------------------
/docs/api/commands/attach.md:
--------------------------------------------------------------------------------
1 | # attach
2 |
3 | Usage: docker attach [OPTIONS] CONTAINER
4 |
5 | Attach to a running container
6 |
7 | --detach-keys Override the key sequence for detaching a container
8 | --no-stdin=false Do not attach STDIN
9 | --sig-proxy=true Proxy all received signals to the process
10 |
11 | The `docker attach` command allows you to attach to a running container using
12 | the container's ID or name, either to view its ongoing output or to control it
13 | interactively. You can attach to the same contained process multiple times
14 | simultaneously, screen sharing style, or quickly view the progress of your
15 | daemonized process.
16 |
17 | You can detach from the container and leave it running with `CTRL-p
18 | CTRL-q` (for a quiet exit) or with `CTRL-c` if `--sig-proxy` is false.
19 |
20 | If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT`
21 | to the container.
22 |
23 | >**Note**: A process running as PID 1 inside a container is treated
24 | >specially by Linux: it ignores any signal with the default action.
25 | >So, the process will not terminate on `SIGINT` or `SIGTERM` unless it is
26 | >coded to do so.
27 |
28 | It is forbidden to redirect the standard input of a `docker attach` command while
29 | attaching to a tty-enabled container (i.e.: launched with `-t`).
30 |
31 | ## Examples
32 |
33 | $ docker run -d --name topdemo ubuntu /usr/bin/top -b
34 | $ docker attach topdemo
35 | top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
36 | Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
37 | Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
38 | Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
39 | Swap: 786428k total, 0k used, 786428k free, 221740k cached
40 |
41 | PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
42 | 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
43 |
44 | top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
45 | Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
46 | Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
47 | Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
48 | Swap: 786428k total, 0k used, 786428k free, 221776k cached
49 |
50 | PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
51 | 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
52 |
53 |
54 | top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
55 | Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
56 | Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
57 | Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
58 | Swap: 786428k total, 0k used, 786428k free, 221776k cached
59 |
60 | PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
61 | 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
62 | ^C$
63 | $ echo $?
64 | 0
65 | $ docker ps -a | grep topdemo
66 | 7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo
67 |
68 | And in this second example, you can see the exit code returned by the `bash` process
69 | is returned by the `docker attach` command to its caller too:
70 |
71 | $ docker run --name test -d -it debian
72 | 275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
73 | $ docker attach test
74 | $$ exit 13
75 | exit
76 | $ echo $?
77 | 13
78 | $ docker ps -a | grep test
79 | 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
80 |
81 | ## Divergence
82 |
83 | - `--detach-keys` option is unsupported.
84 |
85 | ## Related
86 |
87 | - [`docker start`](../commands/start.md) as in `docker start -a $(docker ps -l -q)`
88 |
--------------------------------------------------------------------------------
/docs/api/commands/cp.md:
--------------------------------------------------------------------------------
1 | # cp
2 |
3 | Copy files/folders between a container and the local filesystem.
4 |
5 | Usage: docker cp [options] CONTAINER:PATH LOCALPATH|-
6 | docker cp [options] LOCALPATH|- CONTAINER:PATH
7 |
8 | --help Print usage statement
9 | -L, --follow-link Always follow symbol link in SRC_PATH
10 |
11 | In the first synopsis form, the `docker cp` utility copies the contents of `PATH`
12 | from the filesystem of `CONTAINER` to the `LOCALPATH` (or stream as a tar archive
13 | to `STDOUT` if `-` is specified).
14 |
15 | In the second synopsis form, the contents of `LOCALPATH` (or a tar archive streamed
16 | from `STDIN` if `-` is specified) are copied from the local machine to `PATH` in
17 | the filesystem of `CONTAINER`.
18 |
19 | You can copy to or from either a running or stopped container. The `PATH` can be a
20 | file or directory. The `docker cp` command assumes all `CONTAINER:PATH` values are
21 | relative to the `/` (root) directory of the container. This means supplying the
22 | initial forward slash is optional. The command sees
23 | `compassionate_darwin:/tmp/foo/myfile.txt` and `compassionate_darwin:tmp/foo/myfile.txt`
24 | as identical. If a `LOCALPATH` value is not absolute, is it considered relative to
25 | the current working directory.
26 |
27 | Behavior is similar to the common Unix utility `cp -a` in that directories are
28 | copied recursively with permissions preserved if possible. Ownership is set to the
29 | user and primary group on the receiving end of the transfer. For example, files
30 | copied to a container will be created with `UID:GID` of the root user. Files copied
31 | to the local machine will be created with the `UID:GID` of the user which invoked
32 | the `docker cp` command.
33 |
34 | Assuming a path separator of `/`, a first argument of `SRC_PATH` and second argument
35 | of `DST_PATH`, the behavior is as follows:
36 |
37 | - `SRC_PATH` specifies a file
38 | * `DST_PATH` does not exist
39 | the file is saved to a file created at `DST_PATH`
40 | * `DST_PATH` does not exist and ends with `/`
41 | Error condition: the destination directory must exist.
42 | * `DST_PATH` exists and is a file
43 | the destination is overwritten with the contents of the source file
44 | * `DST_PATH` exists and is a directory
45 | the file is copied into this directory using the basename from `SRC_PATH`
46 | - `SRC_PATH` specifies a directory
47 | * `DST_PATH` does not exist
48 | `DST_PATH` is created as a directory and the contents of the source directory are copied into this directory
49 | * `DST_PATH` exists and is a file
50 | Error condition: cannot copy a directory to a file
51 | * `DST_PATH` exists and is a directory
52 | - `SRC_PATH` does not end with `/.`
53 | the source directory is copied into this directory
54 | - `SRC_PATH` does end with `/.`
55 | the content of the source directory is copied into this directory
56 |
57 | The command requires `SRC_PATH` and `DST_PATH` to exist according to the above rules.
58 | If `SRC_PATH` is local and is a symbolic link, the symbolic link, not the target, is copied.
59 |
60 | A colon (`:`) is used as a delimiter between `CONTAINER` and `PATH`, but : could also
61 | be in a valid `LOCALPATH`, like `file:name.txt`. This ambiguity is resolved by requiring
62 | a `LOCALPATH` with a `:` to be made explicit with a relative or absolute path, for example:
63 |
64 | ```
65 | `/path/to/file:name.txt` or `./file:name.txt`
66 | ```
67 |
68 | It is not possible to copy certain system files such as resources under `/proc`,
69 | `/sys`, `/dev`, and mounts created by the user in the container.
70 |
71 | Using `-` as the first argument in place of a `LOCALPATH` will stream the contents
72 | of `STDIN` as a tar archive which will be extracted to the `PATH` in the filesystem
73 | of the destination container. In this case, `PATH` must specify a directory.
74 |
75 | Using `-` as the second argument in place of a `LOCALPATH` will stream the contents
76 | of the resource from the source container as a tar archive to `STDOUT`.
77 |
78 | ## Divergence
79 |
80 | - `-L` and --follow-link` options are unsupported.
81 |
82 | ## Related
83 |
84 | - Insert a list of related Docker and CloudAPI methods here
85 |
--------------------------------------------------------------------------------
/docs/api/commands/diff.md:
--------------------------------------------------------------------------------
1 | # diff
2 |
3 | ## Divergence
4 |
5 | - This command is currently unimplemented. Follow [DOCKER-73](http://smartos.org/bugview/DOCKER-73) for progress updates.
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/events.md:
--------------------------------------------------------------------------------
1 | # events
2 |
3 | ## Divergence
4 |
5 | This command is currently unimplemented. Follow [DOCKER-78](http://smartos.org/bugview/DOCKER-78) for progress.
6 |
7 | ## Related
8 |
9 | * [`sdc-getmachineaudit`](https://apidocs.tritondatacenter.com/cloudapi/#MachineAudit) and `GET /my/machines/:id/audit` in CloudAPI
10 |
--------------------------------------------------------------------------------
/docs/api/commands/exec.md:
--------------------------------------------------------------------------------
1 | # exec
2 |
3 | Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
4 |
5 | Run a command in a running container
6 |
7 | -d, --detach=false Detached mode: run command in the background
8 | --detach-keys Override the key sequence for detaching a container
9 | -i, --interactive=false Keep STDIN open even if not attached
10 | --privileged Give extended privileges to the command
11 | -t, --tty=false Allocate a pseudo-TTY
12 | -u, --user= Username or UID (format: [:])
13 |
14 | The `docker exec` command runs a new command in a running container.
15 |
16 | The command started using `docker exec` only runs while the container's primary
17 | process (`PID 1`) is running, and it is not restarted if the container is restarted.
18 |
19 | If the container is paused, then the `docker exec` command will fail with an error:
20 |
21 | $ docker pause test
22 | test
23 | $ docker ps
24 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25 | 1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test
26 | $ docker exec test ls
27 | FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
28 | $ echo $?
29 | 1
30 |
31 | ## Examples
32 |
33 | $ docker run --name ubuntu_bash --rm -i -t ubuntu bash
34 |
35 | This will create a container named `ubuntu_bash` and start a Bash session.
36 |
37 | $ docker exec -d ubuntu_bash touch /tmp/execWorks
38 |
39 | This will create a new file `/tmp/execWorks` inside the running container
40 | `ubuntu_bash`, in the background.
41 |
42 | $ docker exec -it ubuntu_bash bash
43 |
44 | This will create a new Bash session in the container `ubuntu_bash`.
45 |
46 | ## Divergence
47 |
48 | * `--detach-keys` is unsupported.
49 | * `--privileged` is unsupported.
50 |
51 | ## Related
52 |
53 | - [`docker logs`](../commands/logs.md)
54 |
--------------------------------------------------------------------------------
/docs/api/commands/export.md:
--------------------------------------------------------------------------------
1 | # export
2 |
3 | ## Divergence
4 |
5 | - This command is currently unimplemented. Follow [DOCKER-73](http://smartos.org/bugview/DOCKER-73) for progress updates.
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/history.md:
--------------------------------------------------------------------------------
1 | # history
2 |
3 | Usage: docker history [OPTIONS] IMAGE
4 |
5 | Show the history of an image
6 |
7 | -H, --human=true Print sizes and dates in human readable format
8 | --no-trunc=false Don't truncate output
9 | -q, --quiet=false Only show numeric IDs
10 |
11 | To see how the `docker:latest` image was built:
12 |
13 | $ docker history docker
14 | IMAGE CREATED CREATED BY SIZE COMMENT
15 | 3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B
16 | 8578938dd170 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB
17 | be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB
18 | 4b137612be55 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB
19 | 750d58736b4b 6 weeks ago /bin/sh -c #(nop) MAINTAINER Tianon Gravi '
50 | * Operating System will always be 'SmartDataCenter'
51 | * SDCAccount will show you the name of the SDC account you're authenticated as
52 | * Name will show you the datacenter name
53 |
54 | Please file a ticket if you discover any additional divergence.
55 |
56 | ## Related
57 |
58 | - Insert a list of related Docker and CloudAPI methods here
59 |
--------------------------------------------------------------------------------
/docs/api/commands/inspect.md:
--------------------------------------------------------------------------------
1 | # inspect
2 |
3 | Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
4 |
5 | Return low-level information on a container or image
6 |
7 | -f, --format="" Format the output using the given go template
8 | -s, --size Display total file sizes if the type is container
9 | --type=container|image Return JSON for specified type, permissible
10 | values are "image" or "container"
11 |
12 | By default, this will render all results in a JSON array. If a format is
13 | specified, the given template will be executed for each result.
14 |
15 | Go's [text/template](http://golang.org/pkg/text/template/) package
16 | describes all the details of the format.
17 |
18 | ## Examples
19 |
20 | **Get an instance's IP address:**
21 |
22 | For the most part, you can pick out any field from the JSON in a fairly
23 | straightforward manner.
24 |
25 | $ docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
26 |
27 | **Get an instance's MAC Address:**
28 |
29 | For the most part, you can pick out any field from the JSON in a fairly
30 | straightforward manner.
31 |
32 | $ docker inspect --format='{{.NetworkSettings.MacAddress}}' $INSTANCE_ID
33 |
34 | **Get an instance's log path:**
35 |
36 | $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
37 |
38 | **List All Port Bindings:**
39 |
40 | One can loop over arrays and maps in the results to produce simple text
41 | output:
42 |
43 | $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
44 |
45 | **Find a Specific Port Mapping:**
46 |
47 | The `.Field` syntax doesn't work when the field name begins with a
48 | number, but the template language's `index` function does. The
49 | `.NetworkSettings.Ports` section contains a map of the internal port
50 | mappings to a list of external address/port objects, so to grab just the
51 | numeric public port, you use `index` to find the specific port map, and
52 | then `index` 0 contains the first object inside of that. Then we ask for
53 | the `HostPort` field to get the public address.
54 |
55 | $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
56 |
57 | **Get config:**
58 |
59 | The `.Field` syntax doesn't work when the field contains JSON data, but
60 | the template language's custom `json` function does. The `.config`
61 | section contains complex JSON object, so to grab it as JSON, you use
62 | `json` to convert the configuration object into JSON.
63 |
64 | $ docker inspect --format='{{json .config}}' $INSTANCE_ID
65 |
66 | ## Divergence
67 |
68 | Some fields, including the following, are irrelevent to containers on Triton and are never populated.
69 |
70 | - AppArmorProfile
71 | - Config: Cpuset, CpuPeriod, CpusetCpus, CpusetMems, CpuQuota, BlkioWeight, ConsoleSize, GroupAdd, LogConfig,
72 | MemorySwappiness, OomKillDisable, Privileged, PortBindings, Ulimits, VolumeDriver
73 | - GraphicDriver: All
74 | - HostConfig: CapAdd, CapDrop, IpcMode, LxcConf, PublishService, SecurityOpt
75 | - Mounts: All
76 | - NetworkSettings: EndpointID, GlobalIPv6Address, GlobalIPv6PrefixLen, HairpinMode, IPv6Gateway,
77 | LinkLocalIPv6Address, LinkLocalIPv6PrefixLen, NetworkID, PortMapping, SandboxKey
78 | SecondaryIPAddresses, SecondaryIPv6Addresses
79 | - State: Dead, OOMKilled
80 |
81 | Also note that the Config.Labels will include the special 'com.joyent.package'
82 | value which will be set to the current name of the package associated with this
83 | VM.
84 |
85 | Read more about container [security on Triton](features/security.md) and see [notes about exit status](../divergence.md).
86 |
87 | The `-s` and `--size` options are currently unsupported.
88 |
89 | Please file a ticket if you discover any additional divergence.
90 |
91 | ## Related
92 |
93 | - [`docker port`](../commands/port.md) as in `docker port $(docker ps -l -q)`
94 | - [`sdc-getmachine`](https://apidocs.tritondatacenter.com/cloudapi/#GetMachine) and `GET /my/machines/:id` in CloudAPI
95 |
--------------------------------------------------------------------------------
/docs/api/commands/kill.md:
--------------------------------------------------------------------------------
1 | # kill
2 |
3 | Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
4 |
5 | Kill a running container using SIGKILL or a specified signal
6 |
7 | -s, --signal="KILL" Signal to send to the container
8 |
9 | The main process inside the container will be sent `SIGKILL`, or any
10 | signal specified with option `--signal`.
11 |
12 | ## Divergence
13 |
14 | SDC Docker only supports a subset of signals for `docker kill`. These currently include:
15 |
16 | - `SIGABRT`
17 | - `SIGALRM`
18 | - `SIGBUS`
19 | - `SIGCHLD`
20 | - `SIGCONT`
21 | - `SIGFPE`
22 | - `SIGHUP`
23 | - `SIGILL`
24 | - `SIGINT`
25 | - `SIGIO`
26 | - `SIGIOT`
27 | - `SIGKILL`
28 | - `SIGLOST`
29 | - `SIGPIPE`
30 | - `SIGPOLL`
31 | - `SIGPROF`
32 | - `SIGPWR`
33 | - `SIGQUIT`
34 | - `SIGSEGV`
35 | - `SIGSTOP`
36 | - `SIGSYS`
37 | - `SIGTERM`
38 | - `SIGTRAP`
39 | - `SIGTSTP`
40 | - `SIGTTIN`
41 | - `SIGTTOU`
42 | - `SIGURG`
43 | - `SIGUSR1`
44 | - `SIGUSR2`
45 | - `SIGVTALRM`
46 | - `SIGWINCH`
47 | - `SIGXCPU`
48 | - `SIGXFSZ`
49 |
50 | Please file a ticket if you discover any additional divergence.
51 |
52 | ## Related
53 |
54 | - [`docker stop`](../commands/stop.md) as in `docker stop $(docker ps -a -q)`
55 | - [`sdc-stopmachine`](https://apidocs.tritondatacenter.com/cloudapi/#StopMachine) and `POST /my/machines/:id?action=stop` in CloudAPI
56 |
--------------------------------------------------------------------------------
/docs/api/commands/load.md:
--------------------------------------------------------------------------------
1 | # load
2 |
3 | ## Divergence
4 |
5 | - This command is currently unimplemented. Follow [DOCKER-73](http://smartos.org/bugview/DOCKER-73) for progress updates.
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/login.md:
--------------------------------------------------------------------------------
1 | # login
2 |
3 | Usage: docker login [OPTIONS] [SERVER]
4 |
5 | Register or log in to a Docker registry server, if no server is
6 | specified "https://index.docker.io/v1/" is the default.
7 |
8 | -e, --email="" Email
9 | -p, --password="" Password
10 | -u, --username="" Username
11 |
12 |
13 | ## Examples
14 |
15 | $ docker login
16 |
17 | If you want to login to a self-hosted registry you can specify this by adding
18 | the server name.
19 |
20 | $ docker login myrepo.example.com
21 |
22 | See also [Private registries](../features/repos.md) for more information.
23 |
24 | ## Divergence
25 |
26 | There is no known divergence between the Triton SDC Docker and Docker Inc.
27 | implementations of this method. Please file a ticket
28 | if you discover any.
29 |
30 | ## Related
31 |
32 | - [`docker logout`](../commands/logout.md)
33 | - [`docker pull`](../commands/pull.md)
34 |
--------------------------------------------------------------------------------
/docs/api/commands/logout.md:
--------------------------------------------------------------------------------
1 | # logout
2 |
3 | Usage: docker logout [SERVER]
4 |
5 | Log out from a Docker registry, if no server is
6 | specified "https://index.docker.io/v1/" is the default.
7 |
8 | ## Examples
9 |
10 | $ docker logout
11 |
12 | If you want to logout from a self-hosted registry you can specify this by adding
13 | the server name.
14 |
15 | $ docker logout myrepo.example.com
16 |
17 | ## Divergence
18 |
19 | There is no known divergence between the Triton SDC Docker and Docker Inc.
20 | implementations of this method. Please file a ticket
21 | if you discover any.
22 |
23 | ## Related
24 |
25 | - [`docker login`](../commands/login.md)
26 |
--------------------------------------------------------------------------------
/docs/api/commands/logs.md:
--------------------------------------------------------------------------------
1 | # logs
2 |
3 | Usage: docker logs [OPTIONS] CONTAINER
4 |
5 | Fetch the logs of a container
6 |
7 | --details Show extra details provided to logs
8 | -f, --follow=false Follow log output
9 | --since="" Show logs since timestamp
10 | -t, --timestamps=false Show timestamps
11 | --tail="all" Number of lines to show from the end of the logs
12 |
13 | NOTE: this command is available only for containers with `json-file` logging
14 | driver.
15 |
16 | The `docker logs` command batch-retrieves logs present at the time of execution.
17 |
18 | The `docker logs --follow` command will continue streaming the new output from
19 | the container's `STDOUT` and `STDERR`.
20 |
21 | Passing a negative number or a non-integer to `--tail` is invalid and the
22 | value is set to `all` in that case. This behavior may change in the future.
23 |
24 | The `docker logs --timestamp` commands will add an RFC3339Nano
25 | timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each
26 | log entry. To ensure that the timestamps for are aligned the
27 | nano-second part of the timestamp will be padded with zero when necessary.
28 |
29 | The --since option shows only the container logs generated after a given date. You can specify the date as an RFC 3339 date, a UNIX timestamp, or a Go duration string (e.g. 1m30s, 3h). Docker computes the date relative to the client machine’s time. You can combine the --since option with either or both of the --follow or --tail options.
30 |
31 | ## Divergence
32 |
33 | - `--details` option is unsupported.
34 |
35 | ## Related
36 |
37 | - Insert a list of related Docker and CloudAPI methods here
38 |
--------------------------------------------------------------------------------
/docs/api/commands/pause.md:
--------------------------------------------------------------------------------
1 | # pause
2 |
3 | ## Divergence
4 |
5 | This command is currently unimplemented. See [OS-3455](http://smartos.org/bugview/OS-3455) to follow progress.
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/port.md:
--------------------------------------------------------------------------------
1 | # port
2 |
3 | Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]]
4 |
5 | List port mappings for the CONTAINER, or lookup the public-facing port that
6 | is NAT-ed to the PRIVATE_PORT
7 |
8 | You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
9 | just a specific mapping:
10 |
11 | $ docker ps test
12 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13 | b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test
14 | $ docker port test
15 | 7890/tcp -> 0.0.0.0:4321
16 | 9876/tcp -> 0.0.0.0:1234
17 | $ docker port test 7890/tcp
18 | 0.0.0.0:4321
19 | $ docker port test 7890/udp
20 | 2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
21 | $ docker port test 7890
22 | 0.0.0.0:4321
23 |
24 | ## Divergence
25 |
26 | There is no known divergence between the Triton SDC Docker and Docker Inc. implementations of this method. Please file a ticket if you discover any.
27 |
28 | ## Related
29 |
30 | - [`sdc-listmachinefirewallrules`](https://apidocs.tritondatacenter.com/cloudapi/#ListMachineFirewallRules) and `GET /my/machines/:id/fwrules` in CloudAPI
31 |
--------------------------------------------------------------------------------
/docs/api/commands/ps.md:
--------------------------------------------------------------------------------
1 | # ps
2 |
3 | CLI Usage: docker ps [OPTIONS]
4 |
5 | List containers
6 |
7 | -a, --all=false Show all containers (default shows just running)
8 | --before="" Show only container created before Id or Name
9 | -f, --filter=[] Filter output based on conditions provided
10 | --format=[] Pretty-print containers using a Go template
11 | -l, --latest=false Show the latest created container, include non-running
12 | -n=-1 Show n last created containers, include non-running
13 | --no-trunc=false Don't truncate output
14 | -q, --quiet=false Only display numeric IDs
15 | -s, --size=false Display total file sizes
16 | --since="" Show created since Id or Name, include non-running
17 |
18 | `docker ps` will show only running containers by default. To see all containers
19 | use `docker ps -a`.
20 |
21 | `docker ps` will group exposed ports into a single range if possible. E.g., a
22 | container that exposes TCP ports `100, 101, 102` will display `100-102/tcp` in
23 | the `PORTS` column.
24 |
25 | ## Filtering
26 |
27 | The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there
28 | is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar"
29 | --filter "bif=baz"`)
30 |
31 | Current filters:
32 |
33 | * id (container's id)
34 | * name (container's name)
35 | * exited (int - the code of exited containers. Only useful with '--all')
36 | * status (restarting|running|paused|exited)
37 |
38 | ## Examples
39 |
40 | ### No output truncation
41 |
42 | Running `docker ps --no-trunc` showing 2 linked containers.
43 |
44 | $ docker ps
45 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
46 | 4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds 3300-3310/tcp webapp
47 | d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db
48 |
49 | ### Containers that exited without errors
50 |
51 | This shows all the containers that have exited with status of '0'
52 |
53 | $ docker ps -a --filter 'exited=0'
54 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55 | ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago Exited (0) 2 weeks ago 127.0.0.1:5000->5000/tcp desperate_leakey
56 | 106ea823fe4e fedora:latest /bin/sh -c 'bash -l' 2 weeks ago Exited (0) 2 weeks ago determined_albattani
57 | 48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds
58 |
59 | ### All containers created before $UUID with total file size
60 |
61 | `GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1`
62 |
63 | ## Divergence
64 |
65 | This command does not support the *Size* field. All sizes will be returned as 0.
66 | See [DOCKER-285](http://smartos.org/bugview/DOCKER-285) to follow this issue.
67 |
68 | Please file a ticket if you discover any additional
69 | divergence.
70 |
71 | ## Related
72 |
73 | * [`docker inspect`](../commands/inspect.md) as in
74 | `docker inspect $(docker ps -l -q)`
75 | * [`docker rm`](../commands/rm.md) as in `docker rm $(docker ps -a -q)`
76 | * [`sdc-listmachines`](https://apidocs.tritondatacenter.com/cloudapi/#ListMachines)
77 | and `GET /my/machines` in CloudAPI
78 | * [`vmadm list`](https://smartos.org/man/1m/vmadm) in SDC private API
79 |
--------------------------------------------------------------------------------
/docs/api/commands/pull.md:
--------------------------------------------------------------------------------
1 | # pull
2 |
3 | Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG]
4 |
5 | Pull an image or a repository from the registry
6 |
7 | -a, --all-tags=false Download all tagged images in the repository
8 | --disable-content-trust=true Skip image verification
9 |
10 | Most of your images will be created on top of a base image from the
11 | [Docker Hub](https://hub.docker.com) registry.
12 |
13 | [Docker Hub](https://hub.docker.com) contains many pre-built images that you
14 | can `pull` and try without needing to define and configure your own.
15 |
16 | It is also possible to manually specify the path of a registry to pull from.
17 | For example, if you have set up a local registry, you can specify its path to
18 | pull from it. A repository path is similar to a URL, but does not contain
19 | a protocol specifier (`https://`, for example).
20 |
21 | To download a particular image, or set of images (i.e., a repository),
22 | use `docker pull`:
23 |
24 | $ docker pull debian
25 | # will pull the debian:latest image and its intermediate layers
26 | $ docker pull debian:testing
27 | # will pull the image named debian:testing and any intermediate
28 | # layers it is based on.
29 | $ docker pull debian@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
30 | # will pull the image from the debian repository with the digest
31 | # sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
32 | # and any intermediate layers it is based on.
33 | # (Typically the empty `scratch` image, a MAINTAINER layer,
34 | # and the un-tarred base).
35 | $ docker pull --all-tags centos
36 | # will pull all the images from the centos repository
37 | $ docker pull registry.hub.docker.com/debian
38 | # manually specifies the path to the default Docker registry. This could
39 | # be replaced with the path to a local registry to pull from another source.
40 | # sudo docker pull myhub.com:8080/test-image
41 |
42 | ## Divergence
43 |
44 | `docker pull -a` and `--disable-content-trust=true` are currently unsupported.
45 | Follow [DOCKER-531](http://smartos.org/bugview/DOCKER-531) for updates.
46 |
47 | The first status line from a `docker pull` shows a UUID:
48 |
49 | $ docker pull busybox
50 | latest: Pulling from busybox (67c12cfb-f717-4bc6-b3a9-b558becf4bbb)
51 | ...
52 |
53 | That UUID is an "request id" for the pull. It can be useful for auditing
54 | and internal debugging of sdc-docker.
55 |
56 |
57 | ## Related
58 |
59 | - [`docker images`](../commands/images.md)
60 | - [`docker rmi`](../commands/rmi.md)
61 |
--------------------------------------------------------------------------------
/docs/api/commands/push.md:
--------------------------------------------------------------------------------
1 | # push
2 |
3 | Usage: docker push [OPTIONS] NAME[:TAG]
4 |
5 | Push an image or a repository to a registry
6 |
7 | --disable-content-trust Skip image signing (default true)
8 | --help Print usage
9 |
10 | ## Divergence
11 |
12 | - This supports only docker v2 image format.
13 |
14 | ## Related
15 |
16 | - [`docker build`](../commands/build.md)
17 | - [`docker commit`](../commands/commit.md)
18 |
--------------------------------------------------------------------------------
/docs/api/commands/rename.md:
--------------------------------------------------------------------------------
1 | # rename
2 |
3 | Usage: docker rename OLD_NAME NEW_NAME
4 |
5 | rename an existing container to a NEW_NAME
6 |
7 | The `docker rename` command allows the container to be renamed to a different name.
8 |
9 | ## Divergence
10 |
11 | There is no known divergence between the Triton SDC Docker and Docker Inc. implementations of this method. Please file a ticket if you discover any.
12 |
13 | ## Related
14 |
15 | * [`sdc-renamemachine`](https://apidocs.tritondatacenter.com/cloudapi/#RenameMachine) and `POST /my/machines/:id?action=rename` in CloudAPI
16 |
--------------------------------------------------------------------------------
/docs/api/commands/restart.md:
--------------------------------------------------------------------------------
1 | # restart
2 |
3 | Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...]
4 |
5 | Restart a running container
6 |
7 | -t, --time=10 Seconds to wait for stop before killing the container
8 |
9 | ## Divergence
10 |
11 | There is no known divergence between the Triton SDC Docker and Docker Inc. implementations of this method. Please file a ticket if you discover any.
12 |
13 | ## Related
14 |
15 | * [`sdc-rebootmachine`](https://apidocs.tritondatacenter.com/cloudapi/#RebootMachine) and `POST /my/machines/:id?action=reboot` in CloudAPI
16 |
--------------------------------------------------------------------------------
/docs/api/commands/rm.md:
--------------------------------------------------------------------------------
1 | # rm
2 |
3 | Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
4 |
5 | Remove one or more containers
6 |
7 | -f, --force=false Force the removal of a running container (uses SIGKILL)
8 | -l, --link=false Remove the specified link
9 | -v, --volumes=false Remove the volumes associated with the container
10 |
11 | ## Examples
12 |
13 | $ docker rm /redis
14 | /redis
15 |
16 | This will remove the container referenced under the link
17 | `/redis`.
18 |
19 | $ docker rm --link /webapp/redis
20 | /webapp/redis
21 |
22 | This will remove the underlying link between `/webapp` and the `/redis`
23 | containers removing all network communication.
24 |
25 | $ docker rm --force redis
26 | redis
27 |
28 | The main process inside the container referenced under the link `/redis` will receive
29 | `SIGKILL`, then the container will be removed.
30 |
31 | $ docker rm $(docker ps -a -q)
32 |
33 | This command will delete all stopped containers. The command `docker ps
34 | -a -q` will return all existing container IDs and pass them to the `rm`
35 | command which will delete them. Any running containers will not be
36 | deleted.
37 |
38 | ## Divergence
39 |
40 | The SDC Docker implementation does not support the following arguments:
41 |
42 | * `--link` does nothing
43 | * `--volumes` does nothing
44 |
45 | Please file a ticket if you discover any additional divergence.
46 |
47 | ## Related
48 |
49 | * [`sdc-deletemachine`](https://apidocs.tritondatacenter.com/cloudapi/#DeleteMachine) and `DELETE /my/machines/:id` in CloudAPI
50 |
--------------------------------------------------------------------------------
/docs/api/commands/rmi.md:
--------------------------------------------------------------------------------
1 | # rmi
2 |
3 | Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
4 |
5 | Remove one or more images
6 |
7 | -f, --force=false Force removal of the image
8 | --no-prune=false Do not delete untagged parents
9 |
10 | ## Removing tagged images
11 |
12 | You can remove an image using its short or long ID, its tag, or its digest. If
13 | an image has one or more tag or digest reference, you must remove all of them
14 | before the image is removed.
15 |
16 | $ docker images
17 | REPOSITORY TAG IMAGE ID CREATED SIZE
18 | test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
19 | test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
20 | test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
21 |
22 | $ docker rmi fd484f19954f
23 | Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
24 | 2013/12/11 05:47:16 Error: failed to remove one or more images
25 |
26 | $ docker rmi test1
27 | Untagged: test1:latest
28 | $ docker rmi test2
29 | Untagged: test2:latest
30 |
31 | $ docker images
32 | REPOSITORY TAG IMAGE ID CREATED SIZE
33 | test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
34 | $ docker rmi test
35 | Untagged: test:latest
36 | Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
37 |
38 | If you use the `-f` flag and specify the image's short or long ID, then this
39 | command untags and removes all images that match the specified ID.
40 |
41 | $ docker images
42 | REPOSITORY TAG IMAGE ID CREATED SIZE
43 | test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
44 | test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
45 | test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
46 |
47 | $ docker rmi -f fd484f19954f
48 | Untagged: test1:latest
49 | Untagged: test:latest
50 | Untagged: test2:latest
51 | Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
52 |
53 | An image pulled by digest has no tag associated with it:
54 |
55 | $ docker images --digests
56 | REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE
57 | localhost:5000/test/busybox sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
58 |
59 | To remove an image using its digest:
60 |
61 | $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
62 | Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
63 | Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
64 | Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
65 | Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
66 |
67 | ## Divergence
68 |
69 | SDC Docker does not support the following arguments for this command:
70 |
71 | * `--no-prune`
72 |
73 | Please file a ticket if you discover any other variance.
74 |
75 | ## Related
76 |
77 | * [`docker images`](../commands/images.md)
78 |
--------------------------------------------------------------------------------
/docs/api/commands/save.md:
--------------------------------------------------------------------------------
1 | # save
2 |
3 | ## Divergence
4 |
5 | - This command is currently unimplemented. Follow [DOCKER-73](http://smartos.org/bugview/DOCKER-73) for progress updates.
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/search.md:
--------------------------------------------------------------------------------
1 | # search
2 |
3 | Search [Docker Hub](https://hub.docker.com) for images
4 |
5 | Usage: docker search [OPTIONS] TERM
6 |
7 | Search the Docker Hub for images
8 |
9 | -f, --filter Filter output based on conditions provided (default [])
10 | --limit Max number of search results (default 25)
11 | --no-trunc=false Don't truncate output
12 | -s, --stars=0 Only displays with at least x stars
13 |
14 | See [*Find Public Images on Docker Hub*](
15 | /userguide/dockerrepos/#searching-for-images) for
16 | more details on finding shared images from the command line.
17 |
18 | > **Note:**
19 | > Search queries will only return up to 25 results
20 |
21 | ## Divergence
22 |
23 | - `-f`, `--filter` and `--limit` options are unsupported.
24 |
25 | ## Related
26 |
27 | - [`docker pull`](../commands/pull.md)
28 |
--------------------------------------------------------------------------------
/docs/api/commands/start.md:
--------------------------------------------------------------------------------
1 | # start
2 |
3 | Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
4 |
5 | Start one or more stopped containers
6 |
7 | -a, --attach=false Attach STDOUT/STDERR and forward signals
8 | --detach-keys Override the key sequence for detaching a container
9 | -i, --interactive=false Attach container's STDIN
10 |
11 | ## Divergence
12 |
13 | * `--detach-keys` is unsupported.
14 |
15 | ## Related
16 |
17 | * [`sdc-startmachine`](https://apidocs.tritondatacenter.com/cloudapi/#StartMachine) and `POST /my/machines/:id?action=start` in CloudAPI
18 |
--------------------------------------------------------------------------------
/docs/api/commands/stats.md:
--------------------------------------------------------------------------------
1 | # stats
2 |
3 | Usage: docker stats CONTAINER [CONTAINER...]
4 |
5 | Display a live stream of one or more containers' resource usage statistics
6 |
7 | -a, --all Show all containers (default shows just running)
8 | --help=false Print usage
9 | --no-stream=false Disable streaming stats and only pull the first result
10 |
11 | Example:
12 |
13 | $ docker stats redis1 redis2
14 | CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O
15 | redis1 0.07% 796 KB / 64 MB 1.21% 788 B / 648 B 3.568 MB / 512 KB
16 | redis2 0.07% 2.746 MB / 64 MB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B
17 |
18 | ## Divergence
19 |
20 | Whilst the major stats (CPU, network, memory) are covered, not all of the
21 | underlying docker stats (cgroups) data points are available, see:
22 |
23 | - [docker-stats.js](https://github.com/TritonDataCenter/sdc/sdc-cn-agent/blob/master/bin/docker-stats.js)
24 |
25 | Also the `-a` and `--all` options are not supported.
26 |
27 | ## Related
28 |
29 | - [Container Monitor 'cmon'](https://github.com/TritonDataCenter/sdc/triton-cmon/tree/master/docs)
30 | - [Container Monitor with Prometheus](https://docs.tritondatacenter.com/public-cloud/api-access/prometheus)
31 |
--------------------------------------------------------------------------------
/docs/api/commands/stop.md:
--------------------------------------------------------------------------------
1 | # stop
2 |
3 | Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
4 |
5 | Stop a running container by sending SIGTERM and then SIGKILL after a
6 | grace period
7 |
8 | -t, --time=10 Seconds to wait for stop before killing it
9 |
10 | The main process inside the container will receive `SIGTERM`, and after a
11 | grace period, `SIGKILL`.
12 |
13 | ## Divergence
14 |
15 | There is no known divergence between the Triton SDC Docker and Docker Inc. implementations of this method. Please file a ticket if you discover any.
16 |
17 | ## Related
18 |
19 | * [`sdc-stopmachine`](https://apidocs.tritondatacenter.com/cloudapi/#StopMachine) and `POST /my/machines/:id?action=stop` in CloudAPI
20 |
--------------------------------------------------------------------------------
/docs/api/commands/tag.md:
--------------------------------------------------------------------------------
1 | # tag
2 |
3 | Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
4 |
5 | Tag an image into a repository
6 |
7 | ## Divergence
8 |
9 | Tag works the same in Triton SDC Docker and Docker Inc, except for below caveat:
10 |
11 | * in Triton SDC Docker, an image cannot have tags that reference two different
12 | registries. Example:
13 |
14 | ```
15 | $ docker tag 123456789 docker.io/user/tagname
16 | $ docker tag 123456789 quay.io/user/tagname (different registry - fails)
17 | ```
18 |
19 | ## Related
20 |
21 | - [`docker build`](../commands/build.md)
22 | - [`docker push`](../commands/push.md)
23 |
--------------------------------------------------------------------------------
/docs/api/commands/top.md:
--------------------------------------------------------------------------------
1 | # top
2 |
3 | Usage: docker top CONTAINER [ps OPTIONS]
4 |
5 | Display the running processes of a container
6 |
7 | ## Divergence
8 |
9 | * With SDC Docker, `docker top` does not currently support the `ps_args` option and always returns results in the same format. This format is hardcoded pending upstream integration of some solution to the issues described in .
10 |
11 | Please file a ticket if you discover any other divergence.
12 |
13 | ## Related
14 |
15 | * [`Analytics`](https://apidocs.tritondatacenter.com/cloudapi/#analytics) in CloudAPI
16 | * [`prstats`](https://smartos.org/man/1M/prstat) SmartOS utility
17 |
--------------------------------------------------------------------------------
/docs/api/commands/unpause.md:
--------------------------------------------------------------------------------
1 | # unpause
2 |
3 | ## Divergence
4 |
5 | - This command is currently unimplemented (blocked on [OS-3456](https://smartos.org/bugview/OS-3456)).
6 |
7 | ## Related
8 |
9 | - Insert a list of related Docker and CloudAPI methods here
10 |
--------------------------------------------------------------------------------
/docs/api/commands/version.md:
--------------------------------------------------------------------------------
1 | # version
2 |
3 | Usage: docker version
4 |
5 | Show the Docker version information.
6 |
7 | -f, --format="" Format the output using the given go template
8 |
9 | Show the Docker version, API version, Git commit, Go version and OS/architecture
10 | of both Docker client and daemon. Example use:
11 |
12 | $ docker version
13 | Client:
14 | Version: 1.8.0
15 | API version: 1.20
16 | Go version: go1.4.2
17 | Git commit: f5bae0a
18 | Built: Tue Jun 23 17:56:00 UTC 2015
19 | OS/Arch: linux/amd64
20 |
21 | Server:
22 | Version: 1.8.0
23 | API version: 1.20
24 | Go version: go1.4.2
25 | Git commit: f5bae0a
26 | Built: Tue Jun 23 17:56:00 UTC 2015
27 | OS/Arch: linux/amd64 Client version: 1.5.0
28 |
29 | ## Divergence
30 |
31 | Known differences:
32 |
33 | - Server version reflects the sdc-docker version, which will vary from the Docker Inc. daemon version.
34 | - Go version on the server is actually a node.js version.
35 |
36 | Please file a ticket if you discover any additional differences.
37 |
38 | ## Related
39 |
40 | - Insert a list of related Docker and CloudAPI methods here
41 |
--------------------------------------------------------------------------------
/docs/api/commands/wait.md:
--------------------------------------------------------------------------------
1 | # wait
2 |
3 | Usage: docker wait CONTAINER [CONTAINER...]
4 |
5 | Block until a container stops, then print its exit code.
6 |
7 | ## Divergence
8 |
9 | There is no known divergence between the Triton SDC Docker and Docker Inc. implementations of this method. Please file a ticket if you discover any.
10 |
11 | See also [notes about exit statuses](../divergence.md).
12 |
13 | ## Related
14 |
15 | - Insert a list of related Docker and CloudAPI methods here
16 |
--------------------------------------------------------------------------------
/docs/api/features/logdrivers.md:
--------------------------------------------------------------------------------
1 | # Log Drivers
2 |
3 | With sdc-docker there is now (limited) support for the --log-driver and
4 | --log-opts functions. Important differences include:
5 |
6 | * sdc-docker does not support the 'journald' driver at all
7 | * the '--log-opt syslog-address' can only be used with the tcp/udp format. The
8 | unix://path format is unsupported as that expects to write to arbitrary host
9 | locations.
10 | * the 'syslog-address' option is *required* when using the syslog log-driver
11 | * the 'fluentd-address' option is *required* when using the fluentd log-driver
12 | * when using any log drivers other than 'json-file' and 'none', additional
13 | processes will be running in your container to handle the logging. All hosts
14 | specified will be resolved from the container. This allows logging for
15 | example on a vxlan network which may not be exposed elsewhere.
16 |
17 | The most important difference however is that the platform that you are using
18 | on your CNs needs to support a given log driver before you'll be able to use it.
19 | If you specify a log driver that is not supported by a CN that you're
20 | provisioning to, one of the following will happen:
21 |
22 | * the driver will be ignored completely (on older platforms)
23 | * the VM will fail to boot after being created
24 | * the driver's options will be ignored (eg. max-file, max-size on json-file)
25 |
26 | In order to reject these sooner so that this does not happen, we have added the
27 | enabledLogDrivers config option which can be set through the SAPI metadata for
28 | the docker service. In order to enable the json-file and none drivers for
29 | example, you can run:
30 |
31 | ```
32 | sdc-sapi /services/$(sdc-sapi /services?name=docker | json -Ha uuid) -X PUT -d '{ "metadata": { "ENABLED_LOG_DRIVERS": "json-file,none" } }'
33 | ```
34 |
35 | from the headnode GZ once you've ensured that the platforms on all your CNs
36 | support these drivers. Also note that all platforms that support LX docker
37 | VMs will work with the json-file driver.
38 |
--------------------------------------------------------------------------------
/docs/api/features/networks.md:
--------------------------------------------------------------------------------
1 | # Networking
2 |
3 | If fabric networking is enabled for sdc-docker, each docker container is
4 | provisioned with a private nic on the user's default fabric. This allows
5 | only other docker containers provisioned on that fabric to connect to each
6 | other. The container is able to reach the external internet via [Network
7 | Address Translation](http://en.wikipedia.org/wiki/Network_address_translation).
8 | Each default fabric network is private to a user - one user's containers cannot
9 | connect to another's fabric IP addresses, and vice-versa.
10 |
11 | To isolate the traffic between different applications or groups of applications,
12 | you may want to create additional networks on your fabric with CloudAPI.
13 | Any of these user-defined networks can be designated as the 'default' network
14 | to be used for provisioning Docker containers. When you change the 'default'
15 | network, it affects only the newly provisioned containers. You may specify
16 | a different fabric network during provisioning by passing the `--network`
17 | argument in `docker run` and `docker create`, e.g.
18 |
19 | docker run --network=dev-net-123 busybox
20 | docker run --network=d8f607e4 -P -d nginx
21 |
22 | The work to support `docker network` commands is in progress. Follow
23 | [DOCKER-722](http://smartos.org/bugview/DOCKER-722),
24 | [DOCKER-723](http://smartos.org/bugview/DOCKER-723),
25 | [DOCKER-724](http://smartos.org/bugview/DOCKER-724),
26 | [DOCKER-725](http://smartos.org/bugview/DOCKER-725) for updates.
27 |
28 | All docker containers owned by a user have firewalls enabled by default, and
29 | their default policy is to block all incoming traffic and allow all outbound
30 | traffic. All docker VMs have a
31 | [Cloud Firewall](https://docs.tritondatacenter.com/public-cloud/network/firewall)
32 | rule automatically created that allows them to communicate with each other on
33 | all ports.
34 |
35 | If you specify the -p or -P options to `docker run` or `docker create`, the
36 | container will receive an external IP address that is reachable over the public
37 | internet, and [Cloud Firewall](https://docs.tritondatacenter.com/public-cloud/network/firewall)
38 | rules are automatically created that allow incoming traffic to the appropriate
39 | ports from any IP address. For `-P`, this means all ports that the VM's image
40 | exposes. For `-p`, this means all ports specified as arguments. Port remapping
41 | (eg, `-p 80:8080`) is not supported at this time. Follow
42 | [DOCKER-341](http://smartos.org/bugview/DOCKER-341) for updates.
43 |
44 | If fabric networking is not enabled, all docker containers are provisioned with
45 | a nic on the 'external' network by default.
46 |
47 | The external network used by a container can be changed by setting the
48 | `triton.network.public` label to the name of the desired external network, e.g.
49 |
50 | docker run --label triton.network.public=external2
51 |
52 | Note that this this only overrides the default public network selection. This
53 | means that when fabric networks are enabled you will still need to specify one
54 | of `-p` or `-P` to get the public NIC.
55 |
56 | ## Related
57 |
58 | * [`sdc-fabric vlan`](https://apidocs.tritondatacenter.com/cloudapi/#CreateFabricVLAN) and `POST /my/fabrics/default/vlans` in CloudAPI
59 | * [`sdc-fabric network`](https://apidocs.tritondatacenter.com/cloudapi/#CreateFabricNetwork) and `POST /my/fabrics/default/vlans/:id/networks` in CloudAPI
60 | * [`sdc-fabric network set-default`](https://apidocs.tritondatacenter.com/cloudapi/#UpdateConfig) and `PUT /my/config` in CloudAPI
61 |
--------------------------------------------------------------------------------
/docs/api/features/repos.md:
--------------------------------------------------------------------------------
1 | # Private registries
2 |
3 | SDC-Docker supports the use of Docker images maintained in the following registries:
4 |
5 | - Docker Hub's public registry
6 | - Docker Hub's private registry
7 | - Self-hosted Docker registry, including Docker Trusted Registry
8 | - quay.io Docker registry
9 | - jFrog Artifactory Docker registry
10 |
11 | Note that Triton sdc-docker only supports v2 registries.
12 |
13 | You can connect to multiple registries at the same time and pull images from them
14 | without having to switch from one to another.
15 |
16 | ## Logging into private registries
17 |
18 | Before searching for or pulling images from the private registries, authenticate to
19 | the registry using the `docker login` command:
20 |
21 | $ docker login [$registryEndpoint]
22 | Username: myrepo
23 | Password:
24 | Email: user@example.com
25 |
26 | When no endpoint is specified, "https://index.docker.io/v1/" is the assumed target.
27 |
28 | Docker client saves your login information in a local configuration file so that
29 | you can keep using the registry without re-authenticating every time.
30 |
31 | For docker client v1.7 or earlier, the registry configurations are located in $HOME/.dockercfg.
32 | For docker client v1.8 or later, the registry configurations are located in $HOME/.docker/config.json.
33 |
34 | When you no longer need a certain registry, you may want to log out from it to erase
35 | the registry configuration to prevent unauthorized use.
36 |
37 | $ docker logout [$registryEndpoint]
38 | Remove login credentials for https://index.docker.io/v1/
39 |
40 | Note that some third-party registries may not have full support for `docker login`
41 | which generates the docker configuration on your client machine. In those cases,
42 | you will have to add the configuration on your own, modeling after the json format and
43 | hashing scheme for credentials created by `docker login` for docker.io, e.g.
44 |
45 | {
46 | "https://myrepo.artifactoryonline.com/v1/": {
47 | "auth": "YFNrZm9u99k6cm9qbzA3",
48 | "email": "user@example.com"
49 | },
50 | "https://index.docker.io/v1/": {
51 | "auth": "YFNrZm9u99k6cm9qbzA3",
52 | "email": "user@example.com"
53 | }
54 | }
55 |
56 | ## Using images in private registries
57 |
58 | An image is uniquely identified by the registry endpoint, repo/image name and tag.
59 | When the registry name is omitted, the image lookup is made in the Docker Hub
60 | public and private registries.
61 |
62 | $ docker pull myrepo/busybox
63 | Pulling repository docker.io/myrepo/busybox
64 | ...
65 |
66 | $ docker run -d quay.io/coreos/etcd
67 | Unable to find image 'quay.io/coreos/etcd:latest' locally
68 | latest: Pulling from quay.io/coreos/etcd
69 | ...
70 |
71 | ## Using images in self-hosted registries
72 |
73 | All self-hosted private repos should have a fully qualified domain name and an
74 | authority-signed certificate for production use. If you need to work with a
75 | test registry that has only a self-signed certificate during the development
76 | cycle, you can do so by enabling the insecure registry setting on your SDC:
77 |
78 | sapiadm update $(sdc-sapi /applications?name=sdc | json -Ha uuid)
79 | metadata.docker_registry_insecure=true
80 |
--------------------------------------------------------------------------------
/docs/api/features/resources.md:
--------------------------------------------------------------------------------
1 | # Resource allocation
2 |
3 | When you create a container with sdc-docker, your container will have an
4 | associated "package". The package will be used to determine such things as:
5 |
6 | * CPU shares
7 | * DRAM (memory)
8 | * Disk quota
9 | * I/O priority
10 |
11 | appropriate for the system your container is provisioned to. The package
12 | parameters can be found using the `triton package list` command using
13 | the [node-triton tool](https://github.com/TritonDataCenter/sdc/node-triton).
14 |
15 | When creating a container with `docker create` or `docker run` you can specify
16 | the package using the special label `com.joyent.package`. This label can be used
17 | with `docker create` or `docker run` to choose a specific package. The value
18 | should be either a package name like `g4-standard-1G`, a UUID or the first 8
19 | characters of a UUID (short-UUID). For example:
20 |
21 | docker run -it --label com.joyent.package=g4-standard-1G alpine /bin/sh
22 |
23 | will create a container using the g4-standard-1G package. If you specify the
24 | com.joyent.package label, any -m argument will be ignored.
25 |
26 | If you don't have a specific package that you want to use but do have a minimum
27 | memory requirement, you can specify a `-m` value for memory and sdc-docker
28 | will select the container package that best matches the resources requested.
29 | If there is no package available with the value specified, it will round up to
30 | the nearest package.
31 |
32 | Regardless of how your docker container was provisioned, you can use the package
33 | as a filter for `docker ps`. To filter you can use the format:
34 |
35 | docker ps --filter "label=com.joyent.package=g4-standard-1G"
36 |
37 | which would show you only those docker containers that are using the
38 | `g4-standard-1G` package.
39 |
40 | For both lookups with `docker ps --filter` and container creation with `docker
41 | create` and `docker run`, you can specify any of package name, package UUID or
42 | the first 8 characters of the package UUID. The order of precedence is:
43 |
44 | 1. package UUID
45 |
46 | If the argument is a UUID, we'll only match UUID
47 |
48 | 2. package name
49 |
50 | If the argument is `/^[0-9a-f]{8}$/` and matches both a uuid and a name,
51 | the package with the name that matches is used. If the argument does not
52 | match the short-UUID pattern, and is not a UUID, it's only looked up
53 | against package names.
54 |
55 | 3. short-UUID
56 |
57 | If the argument is `/^[0-9a-f]{8}$/` and does not match a name, it will
58 | be looked up against the first 8 characters of the available package UUIDs.
59 |
60 | if none of these match you will get an error.
61 |
62 | In order to see the packages for your existing containers you can also do
63 | something like:
64 |
65 | docker ps -a --format '{{.ID}} {{.Label "com.joyent.package"}}'
66 |
67 | which will output the id and package name for each container. If there are
68 | problems looking up the name of the package because you no longer have access to
69 | the package or the package is no longer active, you may see `` as the
70 | package name.
71 |
--------------------------------------------------------------------------------
/docs/api/features/restart.md:
--------------------------------------------------------------------------------
1 | # Restart policies
2 |
3 | The way containers are restarted with sdc-docker:
4 |
5 | * if you specify --restart=no (the default):
6 | * if the node your container is on is rebooted, your container will be off
7 | * if your container process exits (regardless of exit status) your
8 | container will remain off unless you start it.
9 | * if you specify --restart=always:
10 | * if the node your container is on is rebooted, and your container was
11 | running at the time of the reboot, your container will be started when
12 | the node boots.
13 | * if your container process exits (regardless of exit status), the
14 | container will be restarted and the RestartCount will be incremented
15 | (see below on delays between restarts).
16 | * if you specify --restart=on-failure[:maxretries]:
17 | * if the node your container is on is rebooted, your container will only
18 | be started when the node boots if the init process of your container
19 | exited non-zero as part of the CN reboot.
20 | * if your container process exits with a non-zero exit status, the
21 | container will be restarted and the RestartCount will be incremented.
22 | If you specified a maxretries and this is reached, the container will
23 | be stopped and not restarted again automatically.
24 | * if your container process exits with a zero status, the container will
25 | not be restarted again automatically.
26 |
27 | When restarting your container automatically (the cases mentioned above) there
28 | is a delay between restarts in order to prevent things from going haywire.
29 | sdc-docker uses the same delay frequency as Docker Inc's docker. This means that
30 | after exiting but before starting again we delay ((2 ^ RestartCount) * 100) ms.
31 | So on the first restart (with RestartCount = 0) we will delay 100ms, then 200,
32 | then 400, etc. The amount of delay is not guaranteed. In the case of a CN reboot
33 | or in other operational situations a retry may occur sooner.
34 |
35 | The main way that this is different from Docker Inc's docker is that with Docker
36 | Inc's docker, if you restart the docker daemon all containers will be stopped
37 | and those with --restart=always will be started again. With sdc-docker
38 | restarting the management systems will not touch your container but restarting
39 | the compute node the container lives on will.
40 |
41 | If you want your container to always be running you most likely want to specify
42 | --restart=always to avoid your containers being stopped when a CN reboots.
43 |
--------------------------------------------------------------------------------
/docs/api/features/security.md:
--------------------------------------------------------------------------------
1 | # Security
2 |
3 | Details about SDC Docker's runtime environment. Notes that we're not using LXC and don't support privileged containers.
4 |
--------------------------------------------------------------------------------
/docs/api/features/smartos.md:
--------------------------------------------------------------------------------
1 | # SmartOS containers
2 |
3 | Unlike Docker Inc's docker, sdc-docker supports running containers that are
4 | SmartOS-native. Currently this functionality is limited but it is a divergence
5 | from docker. If you specify a UUID of an image that has been imported into
6 | the local imgapi and has the os set to 'smartos', the container will be started
7 | with a joyent-minimal brand instead of lx and will use that image.
8 |
9 |
--------------------------------------------------------------------------------
/docs/api/features/volumes.md:
--------------------------------------------------------------------------------
1 | # Volumes
2 |
3 | With sdc-docker, there are some limitations on volumes that are slightly
4 | different from Docker Inc's docker:
5 |
6 | * there is a limit of 8 'data' volumes per container
7 | * 'host' volumes (/hostpath:/containerpath) are not supported
8 | * you cannot delete a container which has a volume that another container is
9 | sharing (via --volumes-from), you must first delete all containers using that
10 | volume.
11 | * there is a limit of 1 --volumes-from argument per container
12 | * When you use --volumes-from you are necessarily coprovisioned with the
13 | container you are sharing the volumes from. If the physical host on which
14 | the source container exists does not have capacity for the new container,
15 | provisioning a new container using --volumes-from will fail.
16 | * When you use --volumes-from, volumes that don't belong to the container
17 | specified (including those that this container is sharing from others) are
18 | ignored. Only volumes belonging to the specified container will be
19 | considered.
20 |
21 | ## Experimental support for NFS shared volumes
22 |
23 | The NFS shared volumes feature is described in detail by its corresponding [RFD
24 | document](https://github.com/TritonDataCenter/sdc/rfd/blob/master/rfd/0026/README.md).
25 |
26 | To enable support for NFS shared volumes in Triton, run the following command
27 | line from the head node:
28 |
29 | sdcadm post-setup volapi
30 | sdcadm experimental nfs-volumes docker
31 | sdcadm experimental nfs-volumes docker-automount
32 |
33 | This command will create a new core zone that runs the VOLAPI service, which
34 | implements the Volumes API. It will also enable the
35 | `experimental_docker_nfs_shared_volumes` and
36 | `experimental_docker_automount_nfs_shared_volumes` metadata properties in SAPI.
37 |
38 | At this point, all `docker volume` commands are supported but only for the
39 | `'tritonnfs'` volume driver, which provides support for NFS shared volumes. Note
40 | that the `'tritonnfs'` volume driver is considered to be the default and thus
41 | does not need to be specified in the `docker volume create` command for it to
42 | work.
43 |
44 | The `experimental_docker_nfs_shared_volumes` SAPI flag can be set to `false` in
45 | SAPI to disable support for NFS shared volumes by running the following command
46 | line:
47 |
48 | sdcadm experimental nfs-volumes docker -d
49 |
50 | After disabling this setting, running `docker volume` commands will result in an
51 | error message.
52 |
--------------------------------------------------------------------------------
/docs/api/troubleshooting.md:
--------------------------------------------------------------------------------
1 | # SDC Docker client troubleshooting guide
2 |
3 | ## "Couldn't read ca cert ... ca.pem: no such file or directory"
4 |
5 | Your environment is setup to speak to a Docker on SDC
6 |
7 | $ echo $DOCKER_CERT_PATH
8 | /Users/trentm/.sdc/docker/admin
9 | $ echo $DOCKER_HOST
10 | tcp://10.88.88.5:2376
11 | $ alias docker
12 | alias docker='docker --tls'
13 |
14 | but you get a "ca.pem" failure:
15 |
16 | $ docker info
17 | FATA[0000] Couldn't read ca cert /Users/trentm/.sdc/docker/admin/ca.pem: open /Users/trentm/.sdc/docker/admin/ca.pem: no such file or director
18 |
19 | One possibility is that `DOCKER_TLS_VERIFY` is accidentally set:
20 |
21 | $ echo $DOCKER_TLS_VERIFY
22 | 1
23 |
24 | Unset it and try again:
25 |
26 | $ unset DOCKER_TLS_VERIFY
27 | $ docker info
28 | Containers: 0
29 | Images: 33
30 | Storage Driver: sdc
31 | SDCAccount: admin
32 | Execution Driver: sdc-0.1.0
33 | Operating System: SmartDataCenter
34 | Name: coal
35 |
36 | ## Are you trying to connect to a TLS-enabled daemon without TLS?
37 |
38 | You get a "TLS-enabled daemon without TLS" error:
39 |
40 | $ docker info
41 | FATA[0000] Get http:///var/run/docker.sock/v1.17/info: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS
42 |
43 | One possibility is that after running sdc-docker-setup.sh, did you run
44 | the `export` and `alias` commands in your shell.
45 |
46 | Confirm that the env settings are missing:
47 |
48 | $ echo $DOCKER_CERT_PATH
49 |
50 | $ echo $DOCKER_HOST
51 |
52 | $ alias docker
53 | -bash: alias: docker: not found
54 |
55 | Run the exports and alias for your SDC and account, example:
56 |
57 | $ export DOCKER_CERT_PATH=/Users/localuser/.sdc/docker/jill
58 | $ export DOCKER_HOST=tcp://165.225.168.25:2376
59 | $ alias docker="docker --tls"
60 |
61 | Result:
62 |
63 | $ docker info
64 | Containers: 0
65 | Images: 0
66 | Storage Driver: sdc
67 | SDCAccount: jill
68 | Execution Driver: sdc-0.1.0
69 | Operating System: SmartDataCenter
70 | Name: us-east-1
71 |
--------------------------------------------------------------------------------
/docs/development/docker-issues.md:
--------------------------------------------------------------------------------
1 | # Docker Issue Links
2 |
3 | Notes and links to docker issues and PRs on which Triton engineers are involved
4 | or which are particular relevant or interesting.
5 |
6 | ## Networking
7 |
8 | libnetwork IRC discussions:
9 |
10 |
11 | Networking survey:
12 |
13 | *
14 | *
15 |
16 | ## Related to `docker top`
17 |
18 | * [Question about /container/id/top command #7205](https://github.com/docker/docker/issues/7205) (which lead to:)
19 | * [Proposal: Make API for `/containers/(id)/top` independent of implementation #9232](https://github.com/docker/docker/pull/9232)
20 |
21 | ## ZFS
22 |
23 | * [Implement Docker on ZFS](https://github.com/docker/docker/pull/7901). Has first functional version in branch.
24 |
25 | ## Related to `docker stats`
26 |
27 | * [Problems with implementation / doc mismatch on /stats](https://github.com/docker/docker/issues/10711).
28 |
29 | ## Problem with --restart
30 |
31 | * [Issue with --restart=no not being passed by client](https://github.com/docker/docker/issues/10874).
32 | * [The fix for #10874 made things worse](https://github.com/docker/docker/issues/12413).
33 |
34 | ## docker-machine
35 |
36 | * [Add option to skip SSH provisioning](https://github.com/docker/machine/issues/886)
37 |
--------------------------------------------------------------------------------
/docs/development/usage-examples.md:
--------------------------------------------------------------------------------
1 | # Docker usage examples
2 |
3 | ## Delete *all* your docker VMs (helpful when testing)
4 |
5 | ```
6 | docker rm -f `docker ps -aq`
7 | ```
8 |
9 | ## Create a busybox container and play around in it (deleted on exit)
10 |
11 | ```
12 | docker run --rm -it busybox
13 | ```
14 |
15 | ## Create an ubuntu container and play around in it (deleted on exit)
16 |
17 | ```
18 | docker run --rm -it ubuntu
19 | ```
20 |
21 | ## Create an nginx container get the IP make a request then get the logs
22 |
23 | ```
24 | docker run -d nginx
25 | docker inspect --format '{{ .NetworkSettings.IPAddress }}'
26 | curl http://
27 | docker logs
28 | ```
29 |
30 | ## Run a shell in a container (use 'sh' instead of bash if the image doesn't have bash)
31 |
32 | ```
33 | docker exec -it bash
34 | ```
35 |
36 | ## Run a shell in a SmartOS container (non-LX):
37 |
38 | * on headnode:
39 | * ```sdc-imgadm import 00aec452-6e81-11e4-8474-ebfec9a1a911 -S https://images.smartos.org```
40 | * on client:
41 | * ```docker run -it 00aec452-6e81-11e4-8474-ebfec9a1a911 /usr/bin/bash```
42 |
43 | ## Run a shell in a container (destroying when done) with a /data volume
44 |
45 | ```
46 | docker run -it --rm -v /data ubuntu bash
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/development/use-case-Dev2.md:
--------------------------------------------------------------------------------
1 | #Demoing an new application and setting up a node.js development container
2 | ##Docker Use case Dev2
3 | ###Persona : Donna (Senior Developer/Application architect)
4 |
5 | Day #1
6 |
7 | ##General scenario
8 | Donna has a new idea for an application that she wants to share with a remote co-worker so that they can collaborate on the project. She needs a small environment where they can do rapid prototyping and make sure everything works in an standalone environment.
9 |
10 | The project is going to be done in Node.js and they are using github as their source repository.
11 |
12 | She builds a Docker container with node.js and git that pulls the latest code out of the github repository, runs npm install and starts the node.js application. She builds it in a way where that process is invoked every time the container is restarted. That way she doesn’t have to wait for a container to be rebuilt every time there is a new commit. This is a handy trick when doing early prototyping and just wanted to be able to iterate really fast without having to wait for Docker images to be built and moved around.
13 |
14 | The code for the container can be found https://github.com/eviking/mydockerapp and the container itself can be found https://registry.hub.docker.com/u/eviking/mydockerapp/
15 |
16 | ##Steps
17 | ###S1 pulling down the image
18 | Donna goes to hub.docker and locates the following official images for the components in the stack. She is going to use all the latest images.
19 |
20 | ```
21 | $ docker pull eviking/mydockerapp
22 | ```
23 |
24 |
25 | ###S2 Starting the application
26 | Starting the application container
27 | ```
28 | $ docker run --name myApp -d eviking/mydockerapp
29 | ```
30 | A quick test to ensure the container is up and running correctly
31 | ```
32 | $ docker logs myApp
33 | ```
34 | The result she expected looks like this.
35 | ```
36 | Cloning into 'mydockerapp'...
37 | npm WARN package.json my-litle-webserver@0.0.1 No repository field.
38 | npm http GET https://registry.npmjs.org/express
39 | npm http 200 https://registry.npmjs.org/finalhandler/-/finalhandler-0.3.3.tgz
40 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
40 |
44 |
45 |
46 |
47 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | Docker Container Management Daemon (Node.js)
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/smf/method/docker:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2014, Joyent, Inc.
10 | #
11 |
12 | set -o xtrace
13 |
14 | . /lib/svc/share/smf_include.sh
15 |
16 | PATH=/usr/sbin:/usr/bin; export PATH
17 |
18 | case "$1" in
19 | 'start')
20 | /usr/bin/ctrun -l child -o noorphan \
21 | /opt/smartdc/docker/build/node/bin/node \
22 | --abort_on_uncaught_exception \
23 | /opt/smartdc/docker/lib/docker.js &
24 | ;;
25 |
26 | 'stop')
27 | ;;
28 |
29 | *)
30 | echo "Usage: $0 { start | stop }"
31 | exit $SMF_EXIT_ERR_FATAL
32 | ;;
33 | esac
34 | exit $SMF_EXIT_OK
35 |
--------------------------------------------------------------------------------
/test/README.md:
--------------------------------------------------------------------------------
1 | The SDC Docker test suite.
2 |
3 | There are two sets of tests here: *unit* tests which can be run in your local
4 | clone (see "test/unit/") and *integration* tests which are run in an SDC
5 | standup. Eventually the latter will include running Docker's own
6 | "integration-cli" tests.
7 |
8 |
9 | # Usage
10 |
11 | Unit tests should be run before commits:
12 |
13 | make test
14 |
15 | Or you can run a specific test file via:
16 |
17 | cd test
18 | ./runtest unit/foo.test.js
19 |
20 |
21 | Integration tests run from the headnode GZ -- using an LX zone that hosts the
22 | `docker` client the test suites will call. See the "Integration tests design"
23 | section below for why. To run the integration tests use:
24 |
25 | make test-integration-in-coal
26 |
27 | It's also possible to run the integration tests on a per-file basis, though you
28 | will need to set the correct environment variables, example:
29 |
30 | FWAPI_URL=http://10.99.99.26 VMAPI_URL=http://10.99.99.27 node ./test/integration/run-ports.test.js
31 |
32 |
33 | The [nightly](https://jenkins.joyent.us/view/nightly/) test system runs [the
34 | SDC docker tests
35 | nightly](https://jenkins.joyent.us/view/nightly/job/nightly1-095-test-docker/).
36 |
37 |
38 |
39 | # Development Guidelines
40 |
41 | - We are using [tape](https://github.com/substack/tape).
42 |
43 | - Use "test/lib/\*.js" and "test/{unit,integration}/helpers.js" to help make
44 | ".test.js" code more expressive:
45 |
46 | 1. Put setup-y stuff in those files.
47 | 2. Move logical chunks of testing to functions here with
48 | the signature `function (t, opts, callback)`, where `t`
49 | is the test object on which you can assert steps along
50 | the way.
51 |
52 | - Unit tests (i.e. not requiring the full SDC setup) in "unit/\*.test.js".
53 | Integration tests "integration/\*.test.js".
54 |
55 | - When in doubt, follow Rob's style. Structure and style borrows from
56 | sdc-napi.git's and sdc-fwapi.git's test suites.
57 |
58 |
59 | # Integration tests design
60 |
61 | For most (if not all) integration tests a test will:
62 |
63 | 1. run one or more `docker ...` client commands to do something
64 | 2. test that things worked as expected by doing any of:
65 | - running more `docker ...` client commands
66 | - checking internal SDC APIs (sdc-docker admin API, moray, vmapi, etc.)
67 |
68 | IOW, we want to be running a `docker` client somewhere. That means running
69 | those commands, and possibly the whole test suite, on Linux -- and presumably
70 | in an LX zone.
71 |
72 | Ideal: Our ideal is to have a Docker image including the test suite and builds
73 | of the clients, and run that. Each commit to sdc-docker.git would make a new
74 | "sdc-docker-test" image and publish that to updates.joyent.com. However, at the
75 | time of writing we can't yet build Docker images. When we can we'll reconsider
76 | this option.
77 |
78 | Reality: A feasible option right now is to have the test suite (a) create a
79 | generic LX zone (whether a vanilla LX Ubuntu zone, or a docker busybox or
80 | Ubuntu zone is TBD), (b) copy in the docker client with which we'll be testing,
81 | and (c) ssh/zlogin into that zone for each `docker ...` command.
82 |
--------------------------------------------------------------------------------
/test/compose/compose-with-nfs-volume/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2.1"
2 | services:
3 | foo:
4 | image: busybox
5 | volumes:
6 | - compose-with-nfs-volume-test:/bar
7 | network_mode: bridge
8 | volumes:
9 | compose-with-nfs-volume-test:
10 | driver: "tritonnfs"
--------------------------------------------------------------------------------
/test/images/README.md:
--------------------------------------------------------------------------------
1 | This directory holds the data (typically Dockerfile's) needed to
2 | build and push docker images used by the sdc-docker test suite.
3 | By convention, our test images are published to:
4 | https://hub.docker.com/u/joyentunsupported/dashboard/
5 |
6 | These images need to be *manually* built and pushed after any changes,
7 | before running the test suite.
8 |
--------------------------------------------------------------------------------
/test/images/test-image-with-volume/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM busybox
2 | VOLUME /foo
3 | # Create a file within the volume and read from that volume to test both read
4 | # and write access. If any of these commands fails, the exit code of a container
5 | # running this image will be non-zero and will be communicated to the test that
6 | # created it.
7 | CMD echo "bar" > /foo/bar && ls /foo
8 |
--------------------------------------------------------------------------------
/test/images/test-image-with-volume/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # This Source Code Form is subject to the terms of the Mozilla Public
3 | # License, v. 2.0. If a copy of the MPL was not distributed with this
4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | #
6 |
7 | #
8 | # Copyright 2017 Joyent, Inc.
9 | #
10 |
11 | NAME=joyentunsupported/test-image-with-volume
12 | VERSION=1.0.1
13 |
14 | all:
15 | docker build -t $(NAME):$(VERSION) .
16 | docker build -t $(NAME):latest .
17 |
18 | publish: all
19 | docker push $(NAME):$(VERSION)
20 | docker push $(NAME):latest
21 |
--------------------------------------------------------------------------------
/test/images/test-nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:1.13.0-alpine
2 | EXPOSE 80 443
3 | CMD ["nginx", "-g", "daemon off;"]
4 |
--------------------------------------------------------------------------------
/test/images/test-nginx/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # This Source Code Form is subject to the terms of the Mozilla Public
3 | # License, v. 2.0. If a copy of the MPL was not distributed with this
4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | #
6 |
7 | #
8 | # Copyright 2017 Joyent, Inc.
9 | #
10 |
11 | NAME=joyentunsupported/test-nginx
12 | VERSION=1.0.0
13 |
14 | all:
15 | docker build -t $(NAME):$(VERSION) -t $(NAME):latest .
16 |
17 | publish: all
18 | docker push $(NAME):$(VERSION)
19 | docker push $(NAME):latest
20 |
--------------------------------------------------------------------------------
/test/images/test-nginx/README.md:
--------------------------------------------------------------------------------
1 | A simple and *stable* nginx image for use in sdc-docker.git
2 | tests. Before this we often used 'nginx:latest', and hit at
3 | least one bug there it changed its exposed ports that broke
4 | our tests.
5 |
6 | - exposes TCP ports 80 and 443
7 | - uses the nginx-alpine image to be smaller
8 |
--------------------------------------------------------------------------------
/test/integration/api-admin-config.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2017, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Tests for the /admin/config endpoint
13 | */
14 |
15 | var restify = require('restify');
16 | var test = require('tape');
17 |
18 | var adminClient;
19 |
20 | // include the fields from the sapi template
21 | var EXPECTED_FIELDS = [
22 | 'account_allowed_dcs',
23 | 'account_allowed_dcs_msg',
24 | 'adminUuid',
25 | 'backend',
26 | 'binder',
27 | 'cnapi',
28 | 'datacenterName',
29 | 'defaultMaxLogSize',
30 | 'defaultMemory',
31 | 'dockerRegistryInsecure',
32 | 'enabledLogDrivers',
33 | 'externalNetwork',
34 | 'fwapi',
35 | 'httpProxy',
36 | 'imgapi',
37 | 'logLevel',
38 | 'moray',
39 | 'napi',
40 | 'overlay',
41 | 'packagePrefix',
42 | 'papi',
43 | 'port',
44 | 'tls',
45 | 'ufds',
46 | 'useTls',
47 | 'vmapi',
48 | 'wfapi'
49 | ];
50 |
51 | // --- Tests
52 |
53 | test('setup', function (tt) {
54 | tt.test(' create admin client', function (t) {
55 | t.ok(process.env.DOCKER_ADMIN_URL, 'have DOCKER_ADMIN_URL: '
56 | + JSON.stringify(process.env.DOCKER_ADMIN_URL));
57 |
58 | adminClient = restify.createJsonClient({
59 | url: process.env.DOCKER_ADMIN_URL
60 | });
61 | t.ok(adminClient, 'created a restify client');
62 |
63 | t.end();
64 | });
65 | });
66 |
67 | test('test /admin/config', function (tt) {
68 | tt.test(' GET /admin/config', function (t) {
69 | adminClient.get('/admin/config', function onConfig(err, req, res, obj) {
70 | t.ifErr(err, 'getting config should succeed');
71 |
72 | t.ok(obj, 'have config object');
73 |
74 | EXPECTED_FIELDS.forEach(function checkExpectedField(field) {
75 | t.ok(obj.hasOwnProperty(field), 'config should have ' + field
76 | + ', got: ' + JSON.stringify(obj[field]));
77 | });
78 |
79 | t.end();
80 | });
81 | });
82 | });
83 |
--------------------------------------------------------------------------------
/test/integration/api-create-invalid-names.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright 2018, Joyent, Inc.
9 | */
10 |
11 | var vasync = require('vasync');
12 |
13 | var mod_testVolumes = require('../lib/volumes');
14 | var testHelpers = require('./helpers');
15 | var volumesApi = require('../lib/volumes-api');
16 |
17 | var ALICE;
18 | var DOCKER_ALICE;
19 | var STATE = {
20 | log: require('../lib/log')
21 | };
22 |
23 | var test = mod_testVolumes.createTestFunc({
24 | checkTritonSupportsNfsVols: true
25 | });
26 |
27 | test('setup', function (tt) {
28 |
29 | tt.test('docker env', function (t) {
30 | testHelpers.initDockerEnv(t, STATE, {}, function (err, accounts) {
31 | t.ifErr(err);
32 |
33 | ALICE = accounts.alice;
34 |
35 | t.end();
36 | });
37 | });
38 |
39 | tt.test('docker client init', function (t) {
40 | testHelpers.createDockerRemoteClient({
41 | user: ALICE
42 | }, function (err, client) {
43 | t.ifErr(err, 'docker client init for alice');
44 |
45 | DOCKER_ALICE = client;
46 |
47 | t.end();
48 | });
49 | });
50 | });
51 |
52 | test('api: create volumes with invalid name', function (tt) {
53 |
54 | tt.test('docker volume create with invalid name should fail', function (t) {
55 | /*
56 | * 'x'.repeat(257) generates a volume name that is one character too
57 | * long, as the max length for volume names is 256 characters.
58 | */
59 | var INVALID_VOLUME_NAMES = ['-foo', '.foo', 'x'.repeat(257)];
60 |
61 | vasync.forEachParallel({
62 | func: function createVolume(volumeName, done) {
63 | volumesApi.createDockerVolume({
64 | name: volumeName,
65 | dockerClient: DOCKER_ALICE
66 | }, function onVolCreated(volCreateErr) {
67 | t.ok(volCreateErr, 'volume creation with name '
68 | + volumeName + ' should fail');
69 | done();
70 | });
71 | },
72 | inputs: INVALID_VOLUME_NAMES
73 | }, function onAllVolsCreated(err) {
74 | t.end();
75 | });
76 | });
77 | });
--------------------------------------------------------------------------------
/test/integration/api-create-with-volume-from-image.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright 2017, Joyent, Inc.
9 | */
10 |
11 | var test = require('tape');
12 |
13 | var h = require('./helpers');
14 |
15 | var ALICE;
16 | var DOCKER_ALICE;
17 | var STATE = {
18 | log: require('../lib/log')
19 | };
20 | var TEST_IMAGE = 'joyentunsupported/test-image-with-volume:latest';
21 | var VMAPI;
22 |
23 | test('setup', function (tt) {
24 |
25 | tt.test('docker env', function (t) {
26 | h.initDockerEnv(t, STATE, {}, function (err, accounts) {
27 | t.ifErr(err);
28 |
29 | ALICE = accounts.alice;
30 |
31 | t.end();
32 | });
33 | });
34 |
35 | tt.test('docker client init', function (t) {
36 | h.createDockerRemoteClient({user: ALICE}, function (err, client) {
37 | t.ifErr(err, 'docker client init for alice');
38 |
39 | DOCKER_ALICE = client;
40 |
41 | t.end();
42 | });
43 | });
44 |
45 | tt.test('vmapi client init', function (t) {
46 | h.createVmapiClient(function (err, client) {
47 | t.ifErr(err, 'vmapi client');
48 | VMAPI = client;
49 | t.end();
50 | });
51 | });
52 |
53 | });
54 |
55 | test('api: create', function (tt) {
56 |
57 | var created;
58 |
59 | tt.test('docker create', function (t) {
60 | h.createDockerContainer({
61 | start: true,
62 | wait: true,
63 | imageName: TEST_IMAGE,
64 | vmapiClient: VMAPI,
65 | dockerClient: DOCKER_ALICE,
66 | test: t
67 | }, oncreate);
68 |
69 | function oncreate(err, result) {
70 | var expectedExitCode = 0;
71 |
72 | t.ifErr(err, 'create container');
73 | t.ok(result, 'result should not be empty');
74 | t.ok(result.inspect, 'inspect info should not be empty');
75 | t.ok(result.inspect.State,
76 | 'inspect info should have a State property');
77 | if (result && result.inspect && result.inspect.State) {
78 | t.equal(result.inspect.State.ExitCode, expectedExitCode,
79 | 'exit code should be ' + expectedExitCode + ', got: '
80 | + result.inspect.State.ExitCode);
81 | }
82 |
83 | created = result;
84 | t.end();
85 | }
86 | });
87 |
88 | tt.test('docker rm', function (t) {
89 | DOCKER_ALICE.del('/containers/' + created.id, ondel);
90 |
91 | function ondel(err, res, req, body) {
92 | t.ifErr(err, 'rm container');
93 | t.end();
94 | }
95 | });
96 | });
--------------------------------------------------------------------------------
/test/integration/api-info.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for `docker info` using the Remote API directly.
13 | */
14 |
15 | var p = console.log;
16 |
17 | var test = require('tape');
18 | var util = require('util');
19 | var vasync = require('vasync');
20 |
21 | var h = require('./helpers');
22 |
23 |
24 |
25 | // --- Globals
26 |
27 | var ALICE;
28 | var CLIENT;
29 | var STATE = {
30 | log: require('../lib/log')
31 | };
32 |
33 |
34 | // --- Tests
35 |
36 |
37 | test('setup', function (tt) {
38 | tt.test('docker env', function (t) {
39 | h.getDockerEnv(t, STATE, {account: 'sdcdockertest_alice'},
40 | function (err, env) {
41 | t.ifErr(err, 'docker env: alice');
42 | t.ok(env, 'have a DockerEnv for alice');
43 | ALICE = env;
44 |
45 | t.end();
46 | return;
47 | });
48 | });
49 |
50 |
51 | tt.test('client init', function (t) {
52 | h.createDockerRemoteClient({user: ALICE}, function (err, client) {
53 | t.ifErr(err, 'docker client init');
54 | CLIENT = client;
55 | t.end();
56 | });
57 | });
58 | });
59 |
60 |
61 | test('api: info', function (tt) {
62 | tt.test('/info', function (t) {
63 | CLIENT.get('/info', function (err, res, req, body) {
64 | h.assertInfo(t, body);
65 | t.end();
66 | });
67 | });
68 |
69 |
70 | tt.test('/info', function (t) {
71 | CLIENT.get('/info', function (err, res, req, body) {
72 | h.assertInfo(t, body);
73 | t.end();
74 | });
75 | });
76 | });
77 |
--------------------------------------------------------------------------------
/test/integration/cli-commit.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2017, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for `docker commit` using the Remote API directly.
13 | *
14 | * Note: These are only limited tests here, as we rely on the docker/docker
15 | * integration-cli tests to perform most of the sdc-docker build testing,
16 | * which are run separately (e.g. in nightly).
17 | */
18 |
19 | var path = require('path');
20 |
21 | var test = require('tape');
22 | var vasync = require('vasync');
23 |
24 | var cli = require('../lib/cli');
25 | var common = require('../lib/common');
26 | var h = require('./helpers');
27 |
28 | var format = require('util').format;
29 |
30 | var STATE = {
31 | log: require('../lib/log')
32 | };
33 |
34 | var COMMIT_IMAGE_TAG_PREFIX = 'sdcdockertest-commit-image-tag';
35 | var CONTAINER_PREFIX = 'sdcdockertest-commit-container';
36 |
37 | var IMAGE_NAME = 'busybox';
38 | var IMAGE_PREFIX = 'sdcdockertest-commit';
39 | var TP = 'api: commit: '; // Test prefix.
40 |
41 | test(TP + 'setup', function (tt) {
42 |
43 | tt.test('DockerEnv: alice init', cli.init);
44 |
45 | // Ensure the busybox image is around.
46 | tt.test(TP + 'pull busybox image', function (t) {
47 | cli.pull(t, {
48 | image: 'busybox:latest'
49 | });
50 | });
51 | });
52 |
53 |
54 | test(TP + 'test add file', function (tt) {
55 |
56 | var commitImageTag = common.makeResourceName(IMAGE_PREFIX);
57 | var containerName = common.makeResourceName(CONTAINER_PREFIX);
58 |
59 | tt.test('run ' + IMAGE_NAME + ' container', function (t) {
60 | var runArgs = format('--name %s %s sh -c "echo hello > '
61 | + '/newfile.txt"', containerName, IMAGE_NAME);
62 | cli.run(t, {args: runArgs}, t.end.bind(t)); // Err handled in cli.run
63 | });
64 |
65 | tt.test('commit ' + IMAGE_NAME + ' container', function (t) {
66 | var args = format('--author "cli tests" --message "Beer is great" '
67 | + '--change "LABEL test=1" %s %s', containerName, commitImageTag);
68 | cli.commit(t, {args: args}, t.end.bind(t)); // Err handled in commit
69 | });
70 |
71 | // Cleanup out test container and committed image.
72 | tt.test('delete ' + IMAGE_NAME + ' container', function (t) {
73 | cli.rm(t, {args: containerName}, t.end.bind(t)); // Err handled in rm
74 | });
75 |
76 | // Inspect committed image metadata.
77 | tt.test('inspect committed image', function (t) {
78 | cli.inspect(t, {
79 | id: commitImageTag
80 | }, function (err, img) {
81 | if (img) {
82 | t.equal(img.Author, 'cli tests');
83 | t.equal(img.Comment, 'Beer is great');
84 | t.deepEqual(img.Config.Labels, {'test': '1'});
85 | }
86 | t.end();
87 | });
88 | });
89 |
90 | // Run the committed image and verify the 'newfile.txt' contents.
91 | tt.test('verify created image', function (t) {
92 | var runArgs = format('--rm --name %s %s sh -c "cat /newfile.txt"',
93 | common.makeResourceName(CONTAINER_PREFIX + 'verify_'),
94 | commitImageTag);
95 | cli.run(t, {args: runArgs}, function (err, result) {
96 | // err is already tested in cli.run() call
97 | if (!err) {
98 | t.ok(result.stdout.indexOf('hello') >= 0,
99 | 'newfile.txt content is "hello"');
100 | }
101 | t.end();
102 | });
103 | });
104 |
105 | tt.test('delete committed image', function (t) {
106 | cli.rmi(t, {args: commitImageTag}, t.end.bind(t)); // Err handled in rmi
107 | });
108 |
109 | // Ensure base busybox image is still around (and wasn't deleted).
110 | tt.test('inspect busybox image', function (t) {
111 | cli.inspect(t, {
112 | id: IMAGE_NAME
113 | }, t.end.bind(t) /* err checked by cli.inspect */);
114 | });
115 | });
116 |
--------------------------------------------------------------------------------
/test/integration/cli-image-tag.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2017, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for docker image tags.
13 | */
14 |
15 | var cli = require('../lib/cli');
16 | var vm = require('../lib/vm');
17 | var test = require('tape');
18 | var vasync = require('vasync');
19 |
20 |
21 |
22 | // --- Globals
23 |
24 |
25 | var CLIENTS = {};
26 | var TAG_PREFIX = 'sdcdockertest_tag_';
27 | var IMAGE_NAME = 'busybox';
28 |
29 | // --- Helpers
30 |
31 | function cleanupTags(tt) {
32 | tt.test('image tag cleanup', function (t) {
33 | cli.docker('images | grep ' + TAG_PREFIX
34 | + ' | grep -v "" | awk "{ print \\$1 }"',
35 | {}, onComplete);
36 | function onComplete(err, stdout, stderr) {
37 | t.ifErr(err);
38 | var ids = stdout.split(/\r?\n/g).join(' ').trim();
39 | if (!ids) {
40 | t.end();
41 | return;
42 | }
43 | cli.docker('rmi ' + ids, {}, onRemove);
44 | }
45 | function onRemove(err, stdout, stderr) {
46 | t.ifErr(err);
47 | t.end();
48 | }
49 | });
50 | }
51 |
52 | // --- Tests
53 |
54 |
55 | test('setup', function (tt) {
56 | tt.test('DockerEnv: alice init', cli.init);
57 | cleanupTags(tt);
58 | });
59 |
60 |
61 | test('tag image', function (tt) {
62 |
63 | var tagName = TAG_PREFIX + 'altbox';
64 |
65 | tt.test('pull busybox image', function (t) {
66 | cli.pull(t, {
67 | image: 'busybox:latest'
68 | });
69 | });
70 |
71 |
72 | tt.test('inspect busybox image', function (t) {
73 | cli.inspect(t, {
74 | id: 'busybox:latest'
75 | }, function (err, img) {
76 | t.end();
77 | });
78 | });
79 |
80 |
81 | // Tag the image.
82 | tt.test('tag busybox image', function (t) {
83 | cli.docker('tag busybox ' + tagName, {}, onComplete);
84 | function onComplete(err, stdout, stderr) {
85 | t.ifErr(err);
86 | t.end();
87 | }
88 | });
89 |
90 |
91 | // Check that the tagged image is available.
92 | tt.test('inspect tagged image', function (t) {
93 | cli.inspect(t, {
94 | id: tagName + ':latest'
95 | }, function (err, img) {
96 | t.ifErr(err, 'Found tagged image');
97 | t.end();
98 | });
99 | });
100 |
101 |
102 | cleanupTags(tt);
103 |
104 |
105 | // Check that the original busybox image is *still* available after deleting
106 | // the `altbox` tag.
107 | tt.test('inspect busybox image again', function (t) {
108 | cli.inspect(t, {
109 | id: 'busybox:latest'
110 | }, function (err, img) {
111 | t.end();
112 | });
113 | });
114 | });
115 |
116 |
117 | /**
118 | * DOCKER-756: Check can tag an image that references multiple registries.
119 | */
120 | test('DOCKER-756: tag between different registries', function (tt) {
121 |
122 | var tagName = 'quay.io/joyent/' + TAG_PREFIX + 'altbox';
123 |
124 | tt.test('pull busybox image', function (t) {
125 | cli.pull(t, {
126 | image: 'busybox:latest'
127 | });
128 | });
129 |
130 | // Tag the image.
131 | tt.test('tag busybox image', function (t) {
132 | cli.docker('tag busybox ' + tagName, {}, function onComplete(err) {
133 | t.ifErr(err);
134 | t.end();
135 | });
136 | });
137 | });
138 |
--------------------------------------------------------------------------------
/test/integration/cli-info.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for `docker info`
13 | */
14 |
15 | var h = require('./helpers');
16 | var test = require('tape');
17 |
18 |
19 |
20 | // --- Globals
21 |
22 | var log = require('../lib/log');
23 | var state = {
24 | log: log
25 | };
26 | var alice;
27 |
28 |
29 |
30 | // --- Tests
31 |
32 | test('docker info', function (tt) {
33 |
34 | tt.test('setup', function (t) {
35 | h.getDockerEnv(t, state, {account: 'sdcdockertest_alice'},
36 | function (err, env) {
37 | t.ifErr(err);
38 | t.ok(env, 'have a DockerEnv for alice');
39 | alice = env;
40 | t.end();
41 | });
42 | });
43 |
44 | tt.test('docker info (alice)', function (t) {
45 | alice.docker('info', function (err, stdout, stderr) {
46 | t.ifErr(err, 'docker info');
47 | t.ok(/^Storage Driver: sdc$/m.test(stdout), 'Storage Driver: sdc');
48 | t.ok(/SDCAccount: sdcdockertest_alice$/m.test(stdout),
49 | 'SDCAccount: sdcdockertest_alice');
50 | t.ok(/Operating System: SmartDataCenter$/m.test(stdout),
51 | 'Operating System');
52 | t.end();
53 | });
54 | });
55 |
56 | });
57 |
--------------------------------------------------------------------------------
/test/integration/cli-nfs-shared-volumes-create-duplicate-name.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2017, Joyent, Inc.
9 | */
10 |
11 | var assert = require('assert-plus');
12 |
13 | var cli = require('../lib/cli');
14 | var common = require('../lib/common');
15 | var log = require('../lib/log');
16 | var mod_testVolumes = require('../lib/volumes');
17 | var volumesCli = require('../lib/volumes-cli');
18 |
19 | var createTestVolume = mod_testVolumes.createTestVolume;
20 | var test = mod_testVolumes.createTestFunc({
21 | checkTritonSupportsNfsVols: true,
22 | checkDockerClientSupportsNfsVols: true
23 | });
24 |
25 | var NFS_SHARED_VOLUME_NAMES_PREFIX =
26 | mod_testVolumes.getNfsSharedVolumesNamePrefix();
27 |
28 | var ALICE_USER;
29 |
30 | test('setup', function (tt) {
31 | tt.test('DockerEnv: alice init', function (t) {
32 | cli.init(t, function onCliInit(err, env) {
33 | t.ifErr(err, 'Docker environment initialization should not err');
34 | if (env) {
35 | ALICE_USER = env.user;
36 | }
37 | });
38 | });
39 |
40 | // Ensure the busybox image is around.
41 | tt.test('pull busybox image', function (t) {
42 | cli.pull(t, {
43 | image: 'busybox:latest'
44 | });
45 | });
46 | });
47 |
48 | test('Volume creation with same name as existing volume', function (tt) {
49 | var testVolumeName =
50 | common.makeResourceName(NFS_SHARED_VOLUME_NAMES_PREFIX);
51 |
52 | tt.test('creating volume with name ' + testVolumeName + ' should succeed',
53 | function (t) {
54 | volumesCli.createTestVolume(ALICE_USER, {
55 | name: testVolumeName
56 | }, function volumeCreated(err, stdout, stderr) {
57 | t.ifErr(err,
58 | 'volume should have been created successfully');
59 | t.equal(stdout, testVolumeName + '\n',
60 | 'output is newly created volume\'s name');
61 |
62 | t.end();
63 | });
64 | }
65 | );
66 |
67 | tt.test('creating second volume with name ' + testVolumeName + ' should '
68 | + 'fail with appropriate error message',
69 | function (t) {
70 | var expectedErrMsg = '(VolumeAlreadyExists) problem creating '
71 | + 'volume: Volume with name ' + testVolumeName
72 | + ' already exists';
73 |
74 | volumesCli.createTestVolume(ALICE_USER, {
75 | name: testVolumeName
76 | }, function volumeCreated(err, stdout, stderr) {
77 | t.ok(err, 'volume creation should not succeed');
78 | t.ok(stderr.indexOf(expectedErrMsg) !== -1,
79 | 'Error message should include: ' + expectedErrMsg);
80 |
81 | t.end();
82 | });
83 | }
84 | );
85 |
86 | tt.test('removing volume with name ' + testVolumeName + ' should succeed',
87 | function (t) {
88 | volumesCli.rmVolume({
89 | user: ALICE_USER,
90 | args: testVolumeName
91 | }, function onVolumeDeleted(err, stdout, stderr) {
92 | var dockerVolumeOutput = stdout;
93 |
94 | t.ifErr(err,
95 | 'Removing an existing shared volume should not '
96 | + 'error');
97 | t.equal(dockerVolumeOutput, testVolumeName + '\n',
98 | 'Output should be shared volume\'s name');
99 |
100 | t.end();
101 | });
102 | });
103 | });
104 |
--------------------------------------------------------------------------------
/test/integration/cli-run-add-host.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright 2016, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for 'docker run --add-host ...' (aka "ExtraHosts").
13 | */
14 |
15 | var format = require('util').format;
16 | var libuuid = require('libuuid');
17 | var test = require('tape');
18 | var vasync = require('vasync');
19 |
20 | var cli = require('../lib/cli');
21 | var vm = require('../lib/vm');
22 |
23 |
24 | // --- Globals
25 |
26 | var CONTAINER_PREFIX = 'sdcdockertest_runaddhost_';
27 |
28 |
29 | // --- Tests
30 |
31 | test('setup', function (tt) {
32 | tt.test(' test CLI init', cli.init);
33 | tt.test(' vmapi client init', vm.init);
34 | });
35 |
36 |
37 | test('docker run --add-host foo:1.2.3.4', function (tt) {
38 | var containerId;
39 |
40 | var containerName = CONTAINER_PREFIX + libuuid.create().split('-')[0];
41 | tt.ok(containerName, 'containerName: ' + containerName);
42 |
43 | tt.test(' docker run --add-host foo:1.2.3.4 ...', function (t) {
44 | var args = format(
45 | '--add-host foo:1.2.3.4 -d --name %s alpine sleep 3600',
46 | containerName);
47 | cli.run(t, {args: args}, function (err, id) {
48 | t.ifErr(err, 'docker run --add-host foo:1.2.3.4 ...');
49 | containerId = id;
50 | t.end();
51 | });
52 | });
53 |
54 | tt.test(' check VM.internal_metadata["docker:extraHosts"]', function (t) {
55 | vm.get(t, {
56 | id: containerId,
57 | partialExp: {
58 | internal_metadata: {
59 | 'docker:extraHosts': '["foo:1.2.3.4"]'
60 | }
61 | }
62 | });
63 | });
64 |
65 | tt.test(' check that /etc/hosts has the "foo" entry', function (t) {
66 | var cmd = 'exec ' + containerName + ' grep foo /etc/hosts';
67 | cli.docker(cmd, function (err, stdout, stderr) {
68 | t.ifErr(err, 'docker CONTAINER grep foo /etc/hosts');
69 | t.equal(stdout, '1.2.3.4\tfoo\n');
70 | t.end();
71 | });
72 | });
73 |
74 | tt.test(' check that ExtraHosts is set in inspect output', function (t) {
75 | cli.inspect(t, {
76 | id: containerId,
77 | partialExp: {
78 | HostConfig: {
79 | ExtraHosts: ['foo:1.2.3.4']
80 | }
81 | }
82 | });
83 | });
84 | });
85 |
86 |
87 | test('teardown', cli.rmAllCreated);
88 |
--------------------------------------------------------------------------------
/test/integration/cli-search.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for `docker search`
13 | */
14 |
15 | var h = require('./helpers');
16 | var test = require('tape');
17 |
18 |
19 |
20 | // --- Globals
21 |
22 | var log = require('../lib/log');
23 | var state = {
24 | log: log
25 | };
26 | var alice;
27 |
28 |
29 |
30 | // --- Tests
31 |
32 | test('docker search', function (tt) {
33 |
34 | tt.test(' setup', function (t) {
35 | h.getDockerEnv(t, state, {account: 'sdcdockertest_alice'},
36 | function (err, env) {
37 | t.ifErr(err);
38 | t.ok(env, 'have a DockerEnv for alice');
39 | alice = env;
40 | t.end();
41 | });
42 | });
43 |
44 | tt.test(' docker search busybox', function (t) {
45 | alice.docker('search busybox', function (err, stdout, stderr) {
46 | t.ifErr(err);
47 | t.ok(/^busybox /m.test(stdout), 'official busybox image');
48 | t.end();
49 | });
50 | });
51 |
52 | // DOCKER-604 skip this test for now, quay.io search is busted.
53 | tt.skip(' docker search quay.io/quay/elasticsearch', function (t) {
54 | alice.docker('search quay.io/quay/elasticsearch',
55 | function (err, stdout, stderr) {
56 | t.ifErr(err);
57 | t.ok(/^quay\/elasticsearch /m.test(stdout),
58 | 'quay user elasticsearch');
59 | t.end();
60 | });
61 | });
62 |
63 | /*
64 | * This should fail, we don't expect to have any.
65 | *
66 | * It would be nice to fail quickly. E.g. on Docker-docker:
67 | *
68 | * $ time docker search localhost:4321/foo
69 | * FATA[0000] Error response from daemon: v1 \
70 | * ping attempt failed with error: Get \
71 | * http://localhost:4321/v1/_ping: dial tcp 127.0.0.1:5000: \
72 | * connection refused
73 | *
74 | * real 0m0.192s
75 | * user 0m0.150s
76 | * sys 0m0.005s
77 | *
78 | * However, sdc-docker currently takes ~15s to fail here.
79 | */
80 | tt.test(' docker search localhost:4321/foo', function (t) {
81 | alice.docker('search localhost:4321/foo',
82 | function (err, stdout, stderr) {
83 | t.ok(err);
84 | t.end();
85 | });
86 | });
87 |
88 |
89 | });
90 |
--------------------------------------------------------------------------------
/test/integration/foo.test.js.in:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * Integration tests for TODO
13 | */
14 |
15 | var h = require('./helpers');
16 | var test = require('tape');
17 | var util = require('util');
18 |
19 |
20 |
21 | // --- Globals
22 |
23 |
24 |
25 | // --- Helpers
26 |
27 |
28 |
29 | // --- Setup
30 |
31 | test('setup', function (t) {
32 | // ...
33 | });
34 |
35 |
36 |
37 | // --- Tests
38 |
39 | test('blah', function (t) {
40 | // ...
41 | });
42 |
43 |
44 |
45 | // --- Teardown
46 |
47 | test('teardown', function (t) {
48 | // ...
49 | });
50 |
--------------------------------------------------------------------------------
/test/integration/sdcdockertest_client.user-script.in:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o pipefail
5 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
6 | set -o xtrace
7 |
8 | ARCH=x86_64
9 | COMPOSE_AVAILABLE_CLI_VERSIONS="{{COMPOSE_AVAILABLE_CLI_VERSIONS}}"
10 | COMPOSE_RELEASES_BASE_URL=https://github.com/docker/compose/releases/download
11 | DOCKER_AVAILABLE_CLI_VERSIONS="{{DOCKER_AVAILABLE_CLI_VERSIONS}}"
12 | OS=$(uname)
13 |
14 | if [[ ! -d /root/bin ]]; then
15 | mkdir -p /root/bin
16 | echo 'export PATH=/root/bin:$PATH' >>/root/.profile
17 | fi
18 |
19 | cd /root/bin
20 |
21 | if [[ ! -x sdc-docker-setup.sh ]]; then
22 | curl -sSO https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/sdc-docker-setup.sh
23 | chmod +x sdc-docker-setup.sh
24 | fi
25 |
26 | if [[ ! -x get-docker-clients.sh ]]; then
27 | curl -sSO https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/get-docker-clients.sh
28 | chmod +x get-docker-clients.sh
29 | fi
30 |
31 | for compose_cli_version in ${COMPOSE_AVAILABLE_CLI_VERSIONS}; do
32 | if [[ ! -x docker-compose-${compose_cli_version} ]]; then
33 | curl -LsS $COMPOSE_RELEASES_BASE_URL/$compose_cli_version/docker-compose-$OS-$ARCH > docker-compose-${compose_cli_version}
34 | chmod +x docker-compose-${compose_cli_version}
35 | fi
36 | done
37 |
38 | echo "Get docker CLI clients (allow 3 attempts)"
39 | got_docker_clients_successfully=
40 | for i in {3..1}; do
41 | set +o errexit
42 | EXCLUDE_DOCKER_DEBUG=1 ./get-docker-clients.sh ${DOCKER_AVAILABLE_CLI_VERSIONS}
43 | exit_status=$?
44 | set -o errexit
45 | if [[ $exit_status -eq 0 ]]; then
46 | got_docker_clients_successfully=yes
47 | break
48 | fi
49 | done
50 | if [[ "$got_docker_clients_successfully" != "yes" ]]; then
51 | echo "failed to get Docker clients" >&2
52 | exit 1
53 | fi
54 |
55 | touch /var/svc/user-script-done # see waitForClientZoneUserScript
56 |
--------------------------------------------------------------------------------
/test/lib/compose-cli.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2018, Joyent, Inc.
9 | */
10 |
11 | var assert = require('assert-plus');
12 | var vasync = require('vasync');
13 |
14 | /**
15 | * `docker-compose `
16 | *
17 | * @param composeConfig {String} The compose configuration to deploy, typically
18 | * the full content of a docker-compose.yml file.
19 | * @param opts {Object}:
20 | * - args {String} The command (after the 'docker-compose ') to run. E.g.
21 | * 'up -d'.
22 | * - user {Object} The user object passed to `getDockerEnv`'s callback.
23 | * @param callback {Function} `function (err, stdout, stderr)`
24 | */
25 | function cliCompose(composeConfig, opts, callback) {
26 | assert.string(composeConfig, 'composeConfig');
27 | assert.object(opts, 'opts');
28 | assert.string(opts.args, 'opts.args');
29 | assert.object(opts.user, 'opts.user');
30 | assert.func(callback, 'callback');
31 |
32 | var user = opts.user;
33 |
34 | user.compose(composeConfig, opts.args, callback);
35 | }
36 |
37 | module.exports = cliCompose;
--------------------------------------------------------------------------------
/test/lib/log.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | /*
12 | * bunyan logger for tests
13 | */
14 |
15 | var bunyan = require('bunyan');
16 | var restify = require('restify');
17 |
18 | module.exports = bunyan.createLogger({
19 | name: 'sdc-docker-test',
20 | serializers: restify.bunyan.serializers,
21 | streams: [
22 | {
23 | level: process.env.LOG_LEVEL || 'error',
24 | stream: process.stderr
25 | }
26 | ]
27 | });
28 |
--------------------------------------------------------------------------------
/test/runtest:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2015, Joyent, Inc.
10 | #
11 |
12 | # Run a single test of any type.
13 |
14 | if [ "$TRACE" != "" ]; then
15 | export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
16 | set -o xtrace
17 | fi
18 | set -o errexit
19 | set -o pipefail
20 |
21 |
22 | TOP=$(cd $(dirname $0)/../; pwd)
23 | MISSING_FILE="true"
24 | NODE_INSTALL=$TOP/build/node
25 | TAPE=$TOP/node_modules/.bin/tape
26 | UNAME=$(uname -s)
27 |
28 | if [[ -n $1 ]]; then
29 | if [[ -f $1 ]]; then
30 | MISSING_FILE="false"
31 | else
32 | echo "$(basename $0): $1 does not exist" >&2
33 | fi
34 | fi
35 | if [[ ${MISSING_FILE} == "true" || -n $2 ]]; then
36 | echo "Usage: $0 "
37 | exit 2
38 | fi
39 |
40 | # Include common functions (eg. fatal) and perform sanity checks
41 | source $(dirname $0)/runtest.common
42 |
43 | PATH=$NODE_INSTALL/bin:$PATH $TAPE $1
44 |
--------------------------------------------------------------------------------
/test/unit/ports.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This Source Code Form is subject to the terms of the Mozilla Public
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | */
6 |
7 | /*
8 | * Copyright (c) 2015, Joyent, Inc.
9 | */
10 |
11 | var compressPorts = require('../../lib/backends/sdc/utils').compressPorts;
12 |
13 | var test = require('tape');
14 |
15 | var base = mkRangeArray(20, 400)
16 | .concat(mkRangeArray(800, 1100))
17 | .concat(mkRangeArray(5000, 5200));
18 |
19 | /*
20 | * Perform a Fisher-Yates shuffle
21 | */
22 | function shuffle(arr) {
23 | var curr, tmp, other;
24 |
25 | for (curr = arr.length; curr !== 0; ) {
26 | other = Math.floor(Math.random() * curr--);
27 | // Swap the two elements
28 | tmp = arr[curr];
29 | arr[curr] = arr[other];
30 | arr[other] = tmp;
31 | }
32 |
33 | return arr;
34 | }
35 |
36 | /*
37 | * Create an in-order range of numbers from start to end
38 | */
39 | function mkRangeArray(start, end) {
40 | var length = end - start + 1;
41 | var arr = new Array(length);
42 | var i, val;
43 | for (i = 0, val = start; i < length; i++, val++) {
44 | arr[i] = val;
45 | }
46 | return arr;
47 | }
48 |
49 |
50 | /*
51 | * A note about these tests: they were initially written for a more complex
52 | * implementation of compressPorts, so some of them exercise edge cases that
53 | * the current implementation does not have, since it sorts all of the numbers
54 | * at the beginning. They are still valid tests though, and may become more
55 | * relevant again if the implementation changes.
56 | */
57 | [
58 | {
59 | name: 'A single range in increasing order',
60 | input: [ 1, 2, 3, 4, 5, 6, 7, 8 ],
61 | result: [ { start: 1, end: 8 } ]
62 | },
63 | {
64 | name: 'A range and two isolated numbers before and after the range',
65 | input: [ 1, 3, 4, 5, 6, 8 ],
66 | result: [ 1, { start: 3, end: 6 }, 8 ]
67 | },
68 | {
69 | name: 'A range of a numbers and an isolated number after the range ',
70 | input: [1, 3, 4, 2, 5, 6, 8, 2, 2, 5],
71 | result: [ { start: 1, end: 6 }, 8 ]
72 | },
73 | {
74 | name: 'A single element',
75 | input: [ 1 ],
76 | result: [ 1 ]
77 | },
78 | {
79 | name: 'Two ranges in a random order with repeated elements',
80 | input: [ 1, 3, 4, 2, 5, 6, 8, 2, 2, 5, 3, 3, 9, 1 ],
81 | result: [ { start: 1, end: 6 }, { start: 8, end: 9 } ]
82 | },
83 | {
84 | name: 'Range with no input elements whose neighbours are one away',
85 | input: [ 1, 3, 5, 7, 9, 11, 2, 10, 4, 8, 6, 20 ],
86 | result: [ { start: 1, end: 11 }, 20 ]
87 | },
88 | {
89 | name: 'Shuffled range',
90 | input: shuffle(mkRangeArray(20, 400)),
91 | result: [ { start: 20, end: 400 } ]
92 | },
93 | {
94 | name: '2 different ranges shuffled',
95 | input: shuffle(mkRangeArray(20, 400).concat(mkRangeArray(800, 1100))),
96 | result: [ { start: 20, end: 400 }, { start: 800, end: 1100 } ]
97 | },
98 | {
99 | name: '3 different ranges shuffled',
100 | input: shuffle(base),
101 | result: [ { start: 20, end: 400 }, { start: 800, end: 1100 },
102 | { start: 5000, end: 5200 } ]
103 | },
104 | {
105 | name: '3 ranges repeated 4 times and shuffled',
106 | input: shuffle(base.concat(base).concat(base).concat(base)),
107 | result: [ { start: 20, end: 400 }, { start: 800, end: 1100 },
108 | { start: 5000, end: 5200 } ]
109 | }
110 | ].forEach(function (run) {
111 | test(run.name, function (t) {
112 | t.deepEquals(compressPorts(run.input), run.result);
113 | t.end();
114 | });
115 | });
116 |
--------------------------------------------------------------------------------
/tls/ca-key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | Proc-Type: 4,ENCRYPTED
3 | DEK-Info: AES-256-CBC,57B38D65F5C2C26FD213089DEA4980DF
4 |
5 | 3QY5l/BBT5YR5PNTJ6RWd7DDT1dRv6ypHkDxEgmfZPLDa+JVbubIJppUPHatXTcz
6 | 5JPXKQhHuXmo59YVlWugQojh+8TRd13r7MjWUjXUb0MTPIlHbEW3B2J6cZqZQtmJ
7 | Y/ghKteslbpacemzFnCy/glZNk9MW1kDHwEFvpqE3VwT2EH3mmuwju0mEOtOPoca
8 | 3JZG3X05yCnIX2xRwi1CZ5lHdplccwXVKhib5uul8ZHCVc8dhn7+dGbi9CKkSjAU
9 | qxmvGRE0lmyO6as7QBNhSGq5NpjXiib9W6nPUj2RImDGVmfz4GtUrcnvHxYUQhSg
10 | KaLeEoTi3dGLWrAflTa2LYPJPkjuvVj87MyexXjQKBP1ih1FwdfNm7+0eINlOHyA
11 | VZKwRhqWvvXToZlNHEnHClZNTAmt8IQDK3lYmj2teEn24XOUsN0DtnN0PixNExBE
12 | WHtsYi6fHw0ulC05yZYaZdJqBNW/DC68zeOdkrB/Wy1Z53AOQPN/TH/zJoVbdZc+
13 | Lp8gvBL3dv+n6FG2tqNsJEttC2tMt12T3HnS1CvOvAX8UHbeqCVERWJg2Eiz3RE3
14 | +nZD5wk3AS39o+6flGorfYc1dLgX4ZXrrGeqqSFdm7w58pLc1cRPd/cDhh4GHmdb
15 | WD+S7vlMMVwIJgBs8juKyd2pd+GDP3mQH5J0xWUdGcTlXrTrooqafAO4ZQpGFdoT
16 | C4Gd9fr9thmHzSEGOximXbr4MfTuM5go7QxdesHNTZg6yNpLmB5xPo+6rTti1rvT
17 | mwmyRnOPi/mFM7cCVFseUUtE5ANp6J2S5EfyvdsD6gZo3F5f8PcKjz0DGZ2PRMP7
18 | kf22l8ul/OhNM+j3znp7sXRZJy843qqN8s0CUbDzQDryj4/ut521F8eO+oYJQQiF
19 | 9xJjD6JxslCJXw9P16s/om617jaQMDO7nayKXzO3cXB22+vrGk7KwZiGSlT0qmsC
20 | 8L29ULfAMxMZOsFgXlFngWWZmZQ6+BruNdZL50GGfBHi/JDc7sjdGCfx6xLkzaOj
21 | +wE6OU/gEJI7Bh8W1j7RHEHF7GLCFLkF73/+soZvAnJKtYCmWnz0UMpi0ZeNBdue
22 | PsANC0ON4aqAB5MSyUth/B88A2X/txsapo9hwqFpnM0voAu/Oap0n497pLSZ4k4g
23 | eY9XTrTPi2trDiii7xSLxDYNiIANh1WdcjhjxZbQ6n0R/zk8kwDp2vx8urCLI+iz
24 | R4GxSvyLddxH9Tcq7WMiBH63VJA1nqRlbKz0V6+xveDcNoZOXXGHM21YrKu5tn/c
25 | L2G2s++ICYmhMQ0UaM4Z/W3FyXTjc6+gDfGZda956O68SK1QX8ohmsAEJreF25Ym
26 | ZqUxDDW5/7DpLtiR2TDOzA8hGwawU7n4rk2zVl5S4H2pmMTwxWO4DarIE2ph0DFd
27 | +prQjMQXWva3QYYP6SYh4xEfRQgwPgCWLkrPyQtUWZYkhAESCZgYA1VI/CgLFWf8
28 | RCEc3en0v5SwYCeMTYiCuMlzs83o1QsubMUW9Ubpaj8p//8NpS0v/rYYQlf0WDH+
29 | ysxp4LdjeMaRhh11Z+MU6nyGu40G3ZHeePNNk1ifgAlokkfpnLyaQCVM/fcF//ma
30 | -----END RSA PRIVATE KEY-----
31 |
--------------------------------------------------------------------------------
/tls/ca.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDXTCCAkWgAwIBAgIJAOMMJQHNFf2NMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
4 | aWRnaXRzIFB0eSBMdGQwHhcNMTUwMjA0MDYwMjEyWhcNMTYwMjA0MDYwMjEyWjBF
5 | MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
6 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
7 | CgKCAQEAr09oLgEHni1NhX7TBpEHStBUuGTWQHz6k6AIWFOX7QOucP8wWdu/FQwE
8 | +Nf2zItNYrgsjmbgH0ktw5RRwZa77jFUg+mwfQbEWt45XBKXA+WUAlv3xdKHqmQa
9 | PNbgtkiCjsiE5zyzepKRlYbagd8AkAcmxPVc90EKIdVcgRGO79CAqGAq+PP51Bkv
10 | 54U0t41DSWo0AC3+KgA8p2GWPtP+xfYEJTUgezr1IzeKym1GP/NrJ1KQiNNrKxDc
11 | 8BYOAUqAVVBE3NI/WS5v6bNAAhgca8F94v8OQvRo6rril00kNUp6kwq9qweyFPWh
12 | soQGJJOfbw//su2wZtM2PaTflhxnUwIDAQABo1AwTjAdBgNVHQ4EFgQU7chnmqiw
13 | bdrsg9lbmR9TE45KAagwHwYDVR0jBBgwFoAU7chnmqiwbdrsg9lbmR9TE45KAagw
14 | DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAIaB92z7GWot84a2NqN8g
15 | 90PzOYXrg7jBr64U/bniBd/N1FLvbjtJLmSrFw4X0sRA7ew5zFhWNTo9lVuHp0LM
16 | wWoGLDgD910kuYBRMNMbO2EWFoVqvURt2w+s9ZjjYuEPwCjrNLH0GoX6qRlzIiIo
17 | mpAjhdLKppRGsmB+tvvZzJywBh6RfWb32UfEgn+EKLUiFtPSLkdZ3jQ9jSUT1g+R
18 | je3C1X0xV1EARno6vDlJUHloHBS0n2exzt4IXDLXITkYk3q7qU0oPQQI1E2SY0A8
19 | K53Q2Xy80ZVtUMwWpt5xskFUvlTNSMCT28F2SvKLgN3qK3OhxNqgjPf8986jly+U
20 | RQ==
21 | -----END CERTIFICATE-----
22 |
--------------------------------------------------------------------------------
/tls/ca.srl:
--------------------------------------------------------------------------------
1 | 9BC3A26D5524F271
2 |
--------------------------------------------------------------------------------
/tls/cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIC8DCCAdigAwIBAgIJAJvDom1VJPJxMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
4 | aWRnaXRzIFB0eSBMdGQwHhcNMTUwMjA0MDYwNDExWhcNMTYwMjA0MDYwNDExWjAR
5 | MQ8wDQYDVQQDDAZjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
6 | AQCqmRuEGwxxFSgX7saryNVbgpZONh4M4Oftxg99pqZcfshUaL1Mxk+JIsQgCJ4C
7 | W0/PzrEYe8VMwdGKqb+ddf4K4Yn/AF0z3+lzXamYUdIBo9ANKp8UBSgJ1zzv+CCF
8 | HFxj9SZsUmhgJeWL5H0Lu17BNCcFIsautkgIMcdLcLu8iOTTtLasVCKIiaXx3T+E
9 | i2y0oAVgpE5vumGXqUWVsSHnnsVU81FIgPbf2gAn0q4ZRNnkx4IElc8LlsQk/tQF
10 | 9dHNfiLDJT1W9x5fsd6tJz0bFcccs5F+IXbC/sRMfKmtB4aCKkyak61TYbTaZNMZ
11 | 7txIc4r8Uw0R0YH5iClGyOt5AgMBAAGjFzAVMBMGA1UdJQQMMAoGCCsGAQUFBwMC
12 | MA0GCSqGSIb3DQEBBQUAA4IBAQCf5l8gLC+Zcl5pFEOu/eR2kPyevmBdEQoYKiso
13 | eEwz4IuQUytp43CZiuawcRH0TH18y///5qdKVGMyYE2fM6WmlC0COgDZyp5ULfjz
14 | YbPPwAt2Abx1187HH/zlFf27eD7NDwJaNtjahGbQvvy8O+E932MtgNHRMlsvYc4w
15 | 8sB+wx0gPKT4tYFU2WbFUfEdviK/JHnGhFXHJbrPRQ/z58+Osjm8a2xo/fUGXTJt
16 | dN0BGiCLzQ6uPtGF4aSEf4CSmR9XJXJzP7jq6pru8TTM0bHk513aHBQ0wIfN8PQA
17 | NE1jHhu4JKBDjJH2o6yfPJIC0G5hA2LA3UuNPtHz2hNQ7V9x
18 | -----END CERTIFICATE-----
19 |
--------------------------------------------------------------------------------
/tls/extfile.cnf:
--------------------------------------------------------------------------------
1 | extendedKeyUsage = clientAuth
2 |
--------------------------------------------------------------------------------
/tls/key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEowIBAAKCAQEAqpkbhBsMcRUoF+7Gq8jVW4KWTjYeDODn7cYPfaamXH7IVGi9
3 | TMZPiSLEIAieAltPz86xGHvFTMHRiqm/nXX+CuGJ/wBdM9/pc12pmFHSAaPQDSqf
4 | FAUoCdc87/gghRxcY/UmbFJoYCXli+R9C7tewTQnBSLGrrZICDHHS3C7vIjk07S2
5 | rFQiiIml8d0/hItstKAFYKROb7phl6lFlbEh557FVPNRSID239oAJ9KuGUTZ5MeC
6 | BJXPC5bEJP7UBfXRzX4iwyU9VvceX7HerSc9GxXHHLORfiF2wv7ETHyprQeGgipM
7 | mpOtU2G02mTTGe7cSHOK/FMNEdGB+YgpRsjreQIDAQABAoIBACf7D97K9ASAf8/0
8 | Dq1tuMrkdNNJjYtZHiG0XCcHak+dCtf1X//hLfymoC4dtuI4giDigNCLGTce6TvF
9 | Anolj+7+4ndXn4ArxqtZ1Qg0jLIDsRuU1Ik9mB+OSOK4VO69Mc3fQyz5typpVz2M
10 | w91/AProfQiQGN4TLBh3igxdFDJfxLLLBVsjgalgCF0haq8LZbbCKOQ82SjPkcw2
11 | WkrNxbrF1BAdvsXU14UQgENYTHQFKwFpEBdy5QM4MXqJznLOyoRKCo/rm5G20H42
12 | CL4bEK2YEhBLf6hOq1KaAL+x2dfld1h90ZpdPQMDcA8LLbI+CGoH0Jt7y6d//FL1
13 | DTJwlgECgYEA2RCdbopKx6iwFoVdAmAuqwTLT1GcrgweNu7ht7M1p0VwiHieN1q+
14 | 7R/ziCQSfyZ53SdYmt1aNagD2nlaFUEdO5wanVBvctXG/U3Hmx52vu2ITnBeP0lq
15 | xr61W6ipSuRdRI/1lFUraA8K775o3zgJYEvFDF4ibT1TnEqmIMY1PLkCgYEAyTLJ
16 | RjJj0G8dQJlslzT2SYsH1kVWcRM1lUlap8ilcIYWDjmoirn6STBKYvL9geYD23Hg
17 | jU44Co+j1egxVoB800dlxh6eVNMv2+pA9CIaK4c6tHzWZaCIKElnCcWq+a51TNSz
18 | hsgRhnvRgpSOBDn5LLbSwMRrRp6LVZdkTkgtRMECgYEAnSVQNHTeConvYX6PhWbI
19 | ontIDVaSTdbsEO0EcI/Hah/1hnd8Y6rIyrb1AjzLP05Fr3wKw6M46duHXqW4N+b6
20 | GOu8wOM4rDRkaYHj3kNByJwCsHbdZIfsS5JJjeAfH98QPtDSA99dG2q4ijSZi/Dv
21 | qM1yDLAh0GAzpdTNTLDyXdECgYBbYz4ZLHo6Cr52wTmZ1OypqwT8RrJk2hzUmmUb
22 | IQBEhCMwgvATUzZkWBLxrv2HKztFSgx9IrJB2czJNJZ0fBg2v49y1iWE0ghDE7w9
23 | J+BLNTltEecwciJmajDrN2XZ02xkYZjJ98Y+F6+qaF+5e7u6m7BO7ujrQsh3MDTX
24 | eeFWAQKBgBbeNatgOTfRIccIrmBjhTsNvRCCygl15/mzpUmLfDO37FmE/Fihz5gS
25 | zY7/7CF0W3rVoxQ1vHJzqiJsqZqqGol4LgHWhEBppW8NQM65I0jNG4qETgywSVdQ
26 | sQjugU6ytWiAUPE/JQemhko15WQRxr9Xaps2Un616RHvHYqrpNr4
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/tls/server-cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIC4TCCAckCCQCbw6JtVSTycDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
4 | cyBQdHkgTHRkMB4XDTE1MDIwNDA2MDMzNFoXDTE2MDIwNDA2MDMzNFowIDEeMBwG
5 | A1UEAwwVZG9ja2VyLmNvYWwuam95ZW50LnVzMIIBIjANBgkqhkiG9w0BAQEFAAOC
6 | AQ8AMIIBCgKCAQEAx8BAnFSCjKcLO0Zipx4BnOv/3MpDRM0VFOftC1Sf7sa/TYYu
7 | 14v3bGi9EyhZUkLFN9w56OiTaLIoAkdiUn8ZJlanPYLE7551C7WVWtYoxeCIWeJS
8 | UhJcVhY9DYP2bk58dZ4cyPPR1xKZzN0HYd1o6OflmWzG4MuuqfhtkY7RN8wro4ty
9 | b/5T7J1NnR8HXvImfbbY+5cah0+nQni7HB04MWDuDoMOBZhhY72sieCE0EJ2GnIM
10 | BlHQWDqgQr1lK+mvisByCQI+OSjsGgMQ0l8Z3nHfzeQD/7tMiHm3I4l1Vm2C80+I
11 | 8IhLV6teJMZTwjGUc4E9HWYfr65vD3rdxbwyYwIDAQABMA0GCSqGSIb3DQEBBQUA
12 | A4IBAQALIoFPExjdeCwuT9sGoBTJN3Wx1EYuQvG5GBKStn5gezNvsobBx5/bhroO
13 | U5i+1YUm9Ip1lk28oFvd1iusAZua2q/eayMPC6uY5c4up7HhZ4yAPxftWlMODgcP
14 | xU4FWsvSpPcpOJ3li0vhj6KipwjxGHNzy2lrY/6Te/KOw7qhjEizk10WGdb8YM44
15 | Gfsedt5s+DpeZvAXnDq7UbciL5QG/mrNaUGWD08SWuFPbiZCsU+SKZAJ3H7lE/2v
16 | q83rq/nRnDqSHLPgXcNM3wEFrBZSfAXOsHhOL/UjC3kUToGSUluwnk1yBFBlliHE
17 | J8phvkRd2kaD2xNlaDPLZ8LPs5zi
18 | -----END CERTIFICATE-----
19 |
--------------------------------------------------------------------------------
/tls/server-key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEpAIBAAKCAQEAx8BAnFSCjKcLO0Zipx4BnOv/3MpDRM0VFOftC1Sf7sa/TYYu
3 | 14v3bGi9EyhZUkLFN9w56OiTaLIoAkdiUn8ZJlanPYLE7551C7WVWtYoxeCIWeJS
4 | UhJcVhY9DYP2bk58dZ4cyPPR1xKZzN0HYd1o6OflmWzG4MuuqfhtkY7RN8wro4ty
5 | b/5T7J1NnR8HXvImfbbY+5cah0+nQni7HB04MWDuDoMOBZhhY72sieCE0EJ2GnIM
6 | BlHQWDqgQr1lK+mvisByCQI+OSjsGgMQ0l8Z3nHfzeQD/7tMiHm3I4l1Vm2C80+I
7 | 8IhLV6teJMZTwjGUc4E9HWYfr65vD3rdxbwyYwIDAQABAoIBAQDG0w08zj235Nmg
8 | IZo2v/5ZBOuECGvWws+WJJhlK9GZqYhnkQV1FWOtK7/vnrzxzXZi+LlHpKB9mL+M
9 | LSOn+8y7xYroBg8id7YHdrH4Xazt8WWnGkhYWuA/7BjPKCgVedgWdtAuEcsv6dre
10 | +K7NccZn9dMq2QRIY1Uy6A2f0elcQAFSCf0FVf2qVRm8SluYbYRZMlrdBQxHymGf
11 | dJ8fd7hY3uaHjVQLjMK6b6ozzLk3PeOiMgB1RK2vgtImMeoZaIWaiS54OQ9/ARyC
12 | CrGXvypoqgcoFEVnCO93I2fbC3Ipzq4xPL8k96d39Lprd18ckq0V+AM+nezvkLMI
13 | 87wwZClxAoGBAPOJeoe/MqN8M6qqkyLRTX8Fece4PekKuXNoQAQqtj5dAwgxKRAM
14 | 1yKcs9uGeGw91eJd8TLc50D2UAPsG2cpOtN0+AgG7+4U6zGIWcfQvd+3MjOl75T+
15 | UPWVLkEurdvD7HUH0t+6tmsVyOrLo60IejtFrN3MrhYYgL7X/ocu9BkZAoGBANH5
16 | JKP5xg3EjXVHGeC4Ug3ty4DJ+aASoyPAU9Jy3l5TuWPA5nWhgSupNyAAbqZQOR30
17 | AulzbQVXV5ap5nvIOQug/2cWNZ41k6O9fPTnpbdPjfD5TMkYvZwB9PGPtJMsrbDA
18 | S5nC0fbtGujL88GkoZrI1by3o67yZwZ672aipcrbAoGBAMBXZB6yMxxLi8LO1UY6
19 | aCpZ+MR0DvFvNuie/XBNC4JVk3901CmI+qCrgqFuos1aSQJvj3/MWBhGcQun/jyL
20 | o5o+V2Z/lB9FBjwopD/b7RozZcLE22OhN++90rpIU6euJaKIe1OX81q/6d8G1k5i
21 | 06bccJr8fMGWuJgBn1TFEKSBAoGAYJTJ/sbIC9MqAhTnWU9PJusHXUEKGlAYTDyO
22 | EdIWaKr4LmMvXlIgeTXHjmfEfamO7DEuGbWnIvrO5hVWV/98BdZTRFaZ6SDZvUpO
23 | rNPUjOIB9yKk6CcCKD1aLracJ8o4RoHdBGfxbjQX2Zbek2ankuvoLHsHxlPngbqQ
24 | XdRYkFsCgYBQa2h7KmNzGHRSSkl32Tw/6qhfHL7KWRb5EVGf01lnYxLyOP2FOa6v
25 | 3WRor2tHk4FuRgfyNRk3tt8BUktWp8Ld7SV+HgIzpfqdUZzC6c/9h72UG9JpuZXu
26 | 7QwK5CpYXG0a7n+AlCrKrQ4ZqF5YXpBA+cqwgNGkKEj+ESuZjTnbrA==
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/tools/check-docs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2017, Joyent, Inc.
10 | # Copyright 2023 MNX Cloud, Inc.
11 | #
12 |
13 | #
14 | # Some sanity style checks of docs/...
15 | #
16 | # Usage:
17 | # make check
18 | #
19 | # Checks:
20 | #
21 | # 1. Ensure files end with a newline, else the import into
22 | # apidocs.tritondatacenter.com.git gets grumpy.
23 | #
24 | #
25 |
26 | if [[ -n "$TRACE" ]]; then
27 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
28 | set -o xtrace
29 | fi
30 | set -o errexit
31 | set -o pipefail
32 |
33 | TOP=$(cd "$(dirname "$0")/../"; pwd)
34 |
35 |
36 | #---- mainline
37 |
38 | hits=0
39 |
40 | # Check each of the files in docs/. (We use -print0 in case files
41 | # have spaces in their name.)
42 | while read -d $'\0' -r file; do
43 | # Map the newline character into a space, and spaces into
44 | # an underscore, since bash likes to trim trailing newlines
45 | # from command outputs.
46 | if [[ $(tail -1c "$file" | tr ' \n' '_ ') != ' ' ]]; then
47 | echo "$file: does not end with a newline" >&2
48 | hits=1
49 | fi
50 | done < <(find "$TOP/docs" -name "*.md" -print0)
51 |
52 | exit $hits
53 |
--------------------------------------------------------------------------------
/tools/docker-client-env:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2014, Joyent, Inc.
10 | #
11 |
12 | # Dump the environment necessary to setup your docker client to use
13 | # Docker running in a given SDC.
14 | #
15 | # Note: This script does not work with docker using TLS, use sdc-docker-setup.sh
16 | # for TLS support.
17 |
18 | if [[ -n "$TRACE" ]]; then
19 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
20 | set -o xtrace
21 | fi
22 | set -o errexit
23 | set -o pipefail
24 |
25 | HN=$1
26 | if [[ -z "$HN" ]]; then
27 | echo 'docker-client-env: error: no HN argument given' >&2
28 | echo '' >&2
29 | echo 'Usage (include the backticks to update your env):' >&2
30 | echo ' `./tools/docker-client-env HN`' >&2
31 | echo '' >&2
32 | echo 'Examples:' >&2
33 | echo ' $ `./tools/docker-client-env root@10.99.99.7` # COAL' >&2
34 | echo ' $ `./tools/docker-client-env root@172.26.1.4` # nightly-1' >&2
35 | exit 1
36 | fi
37 |
38 |
39 | # Get docker0 IP: the external if it has one, else the first one.
40 | IP=$(ssh $HN "vmadm lookup -j alias=docker0 | json -ae 'ext = this.nics.filter(function (nic) { return nic.nic_tag === \"external\"; })[0]; this.ip = ext ? ext.ip : this.nics[0].ip;' ip")
41 | DOCKER_HOST=tcp://$IP:2375
42 |
43 | echo "# Setting DOCKER_HOST=$DOCKER_HOST" >&2
44 | echo "export DOCKER_HOST=$DOCKER_HOST"
45 | echo "# Unsetting DOCKER_TLS_VERIFY" >&2
46 | echo "export DOCKER_TLS_VERIFY="
47 |
--------------------------------------------------------------------------------
/tools/get-compose-clients.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright 2018, Joyent, Inc.
10 | #
11 |
12 | # Get 'docker' client binaries (from
13 | # https://github.com/docker/compose/releases/download/{{compose_version}}/) By
14 | # default it will get all the docker-compose client versions that sdc-docker.git
15 | # cares about. If given versions it will just download those.
16 | #
17 | # Usage:
18 | # cd ~/opt/dockers
19 | # ~/sdc-docker/tools/get-compose-clients.sh
20 | #
21 | # # Get just a particular version:
22 | # cd ~/opt/dockers
23 | # ~/sdc-docker/tools/get-compose-clients.sh 1.11.0
24 | #
25 |
26 |
27 | if [[ -n "$TRACE" ]]; then
28 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
29 | set -o xtrace
30 | fi
31 | set -o errexit
32 | set -o pipefail
33 | set -o nounset
34 |
35 |
36 | # ---- globals
37 |
38 | # Note: Should keep this in sync with "COMPOSE_AVAILABLE_CLI_VERIONS"
39 | DEFAULT_VERS="1.9.0"
40 |
41 | WRKDIR=/var/tmp/tmp.get-docker-clients
42 | DSTDIR=$(pwd)
43 | OS=$(uname)
44 | ARCH=x86_64
45 | COMPOSE_RELEASES_BASE_URL=https://github.com/docker/compose/releases/download
46 |
47 | # ---- support functions
48 |
49 | function fatal
50 | {
51 | echo "" >&2
52 | echo "* * *" >&2
53 | printf "$NAME: fatal error: $*\n" >&2
54 | exit 1
55 | }
56 |
57 |
58 | function get_compose_client
59 | {
60 | local ver
61 | ver="$1"
62 |
63 | if [[ ! -f $DSTDIR/docker-compose-$ver ]]; then
64 | echo "# Getting docker-compose-$ver"
65 | curl -OsS $COMPOSE_RELEASES_BASE_URL/$ver/docker-compose-$OS-$ARCH
66 | mv docker-compose-$OS-$ARCH $DSTDIR/docker-compose-$ver
67 | chmod 755 $DSTDIR/docker-compose-$ver
68 | $DSTDIR/docker-compose-$ver --version
69 | else
70 | echo "# Already have docker-compose-$ver"
71 | $DSTDIR/docker-compose-$ver --version
72 | fi
73 | }
74 |
75 | # ---- mainline
76 |
77 | versions="$@"
78 | if [[ -z "$versions" ]]; then
79 | versions="$DEFAULT_VERS"
80 | fi
81 |
82 | for ver in $versions; do
83 | get_compose_client "$ver"
84 | done
85 |
--------------------------------------------------------------------------------
/tools/install-docker.js.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2014, Joyent, Inc.
10 | #
11 |
12 | #
13 | # This is the script included in docker.js shars to handle
14 | # the docker.js install/upgrade on a headnode GZ.
15 | #
16 | # Usage:
17 | # install-docker.js.sh # in the extracted shar dir
18 | #
19 |
20 | if [[ -n "$TRACE" ]]; then
21 | export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
22 | set -o xtrace
23 | fi
24 | set -o errexit
25 | set -o pipefail
26 |
27 |
28 | DESTDIR=/opt/smartdc/docker.js
29 | NEWDIR=$DESTDIR.new
30 | OLDDIR=$DESTDIR.old
31 |
32 |
33 | #---- support stuff
34 |
35 | function fatal
36 | {
37 | echo "$0: fatal error: $*" >&2
38 | exit 1
39 | }
40 |
41 | function restore_old_on_error
42 | {
43 | [[ $1 -ne 0 ]] || exit 0
44 |
45 | if [[ -d $OLDDIR ]]; then
46 | echo "$0: restoring $DESTDIR from $OLDDIR"
47 | rm -rf $DESTDIR
48 | mv $OLDDIR $DESTDIR
49 | fi
50 |
51 | fatal "$0: error exit status $1" >&2
52 | }
53 |
54 |
55 | #---- mainline
56 |
57 | # Sanity checks.
58 | [[ "$(zonename)" == "global" ]] || fatal "not running in global zone"
59 | [[ "$(sysinfo | json "Boot Parameters.headnode")" == "true" ]] \
60 | || fatal "not running on the headnode"
61 | [[ -f "./etc/build.json" ]] || fatal "missing './etc/build.json'"
62 |
63 | [[ -d $OLDDIR ]] && rm -rf $OLDDIR
64 | [[ -d $NEWDIR ]] && rm -rf $NEWDIR
65 |
66 | trap 'restore_old_on_error $?' EXIT
67 |
68 | cp -PR ./ $NEWDIR
69 | rm $NEWDIR/install-docker.js.sh
70 | rm -rf $NEWDIR/.temp_bin
71 |
72 | # Move the old out of the way, swap in the new.
73 | if [[ -d $DESTDIR ]]; then
74 | mv $DESTDIR $OLDDIR
75 | fi
76 | mv $NEWDIR $DESTDIR
77 |
78 | # Import the docker engine service and gracefully start it.
79 | echo "Importing and starting docker service"
80 | cp $DESTDIR/smf/manifests/docker.xml /var/svc/manifest/site/docker.xml
81 | svccfg import /var/svc/manifest/site/docker.xml
82 | if [[ "$(svcs -Ho state docker)" == "maintenance" ]]; then
83 | svcadm clear docker
84 | fi
85 |
86 | [[ -d $OLDDIR ]] && rm -rf $OLDDIR
87 |
88 | echo "Successfully upgraded to docker.js $(cat $DESTDIR/etc/build.json)"
89 | exit 0
90 |
--------------------------------------------------------------------------------
/tools/jsstyle.conf:
--------------------------------------------------------------------------------
1 | #
2 | # This Source Code Form is subject to the terms of the Mozilla Public
3 | # License, v. 2.0. If a copy of the MPL was not distributed with this
4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 | #
6 |
7 | #
8 | # Copyright (c) 2014, Joyent, Inc.
9 | #
10 |
11 | indent=4
12 | doxygen
13 | unparenthesized-return=0
14 | blank-after-start-comment=0
15 | leading-right-paren-ok=1
16 | continuation-at-front=1
17 | strict-indent=1
18 |
--------------------------------------------------------------------------------
/tools/md5sum-for-smartos-gz:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2014, Joyent, Inc.
10 | #
11 |
12 | #
13 | # A fake md5sum for gshar to use. Mimicks coreutils' md5sum as much as possible.
14 | #
15 |
16 | num_fails=0
17 |
18 | function checkone() {
19 | expected=$1
20 | path=$2
21 | actual=$(openssl dgst -md5 $path | awk '{print $2}')
22 | if [[ "$actual" == "$expected" ]]; then
23 | echo "$path: OK"
24 | else
25 | echo "$path: FAILED"
26 | num_fails=$(( $num_fails + 1 ))
27 | fi
28 | }
29 |
30 | if [[ $1 == "--version" ]]; then
31 | echo "md5sum from fakey coreutils"
32 | exit 0
33 | fi
34 | if [[ $1 == "-c" ]]; then
35 | shift;
36 | if [[ $# -eq 0 ]]; then
37 | while read line; do
38 | checkone $line
39 | done <&0
40 | else
41 | while [[ $# -ne 0 ]]; do
42 | while read line; do
43 | checkone $line
44 | done <$1
45 | shift
46 | done
47 | fi
48 | if [[ $num_fails -eq 1 ]]; then
49 | echo "md5sum: WARNING: $num_failed computed checksum did NOT match"
50 | elif [[ $num_fails -ne 0 ]]; then
51 | echo "md5sum: WARNING: $num_failed computed checksums did NOT match"
52 | fi
53 | else
54 | openssl dgst -md5 "$@" | sed -E -e 's/^MD5\((.+)\)= (.*)$/\2 \1/'
55 | fi
56 |
--------------------------------------------------------------------------------
/tools/pre-commit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright 2017 Joyent, Inc.
10 | #
11 |
12 | #
13 | # A suggested git pre-commit hook for developers. Install it via:
14 | #
15 | # make git-hooks
16 | #
17 |
18 | set -o errexit
19 | set -o pipefail
20 |
21 | function ensure_copyright_year() {
22 | currYear=$(date -u "+%Y")
23 | filesToBeCommited=$(git diff --staged --name-only HEAD)
24 | nErrs=0
25 | for f in $filesToBeCommited; do
26 | year=$((grep Copyright $f || true) \
27 | | (grep Joyent || true) \
28 | | sed -E 's/^(.*)([0-9]{4})(.*)$/\2/')
29 | if [[ -n "$year" && "$year" != "$currYear" ]]; then
30 | echo "$f: error: Copyright year is $year instead of $currYear"
31 | nErrs=$(( $nErrs + 1 ))
32 | fi
33 | done
34 | if [[ $nErrs -gt 0 ]]; then
35 | exit 1
36 | fi
37 | }
38 |
39 |
40 | #---- mainline
41 |
42 | # Redirect output to stderr.
43 | exec 1>&2
44 |
45 | ensure_copyright_year
46 | make check
47 | make test
48 |
--------------------------------------------------------------------------------
/tools/rsync-to:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 | #
7 |
8 | #
9 | # Copyright (c) 2014, Joyent, Inc.
10 | #
11 |
12 | #
13 | # Rsync the master in this working copy to the install on the given HN.
14 | #
15 |
16 | #set -o xtrace
17 | set -o errexit
18 |
19 | TOP=$(cd $(dirname $0)/../; pwd)
20 | NODE=$1
21 |
22 | if [[ -z "$DOCKER_ZONE" ]]; then
23 | DOCKER_ZONE=$(ssh $NODE "vmadm lookup -1 alias=docker0" 2>/dev/null)
24 | fi
25 | echo "DOCKER_ZONE: $DOCKER_ZONE"
26 |
27 | extraOpts=
28 | if [[ $(uname -s) != "SunOS" ]]; then
29 | extraOpts="--exclude *.node --exclude build"
30 | else
31 | # Clean node_modules everytime.
32 | ssh $NODE rm -rf /zones/$DOCKER_ZONE/root/opt/smartdc/docker/node_modules
33 | fi
34 |
35 | rsync -av ${TOP}/ \
36 | $NODE:/zones/$DOCKER_ZONE/root/opt/smartdc/docker/ \
37 | $extraOpts \
38 | --exclude .git/ \
39 | --exclude /etc/config.json \
40 | --exclude /deps/ \
41 | --exclude /doc/ \
42 | --exclude /tmp/
43 |
44 | state=$(ssh ${NODE} svcs -z ${DOCKER_ZONE} -H -o state docker)
45 | if [[ "$state" == "maintenance" ]]; then
46 | ssh ${NODE} svcadm -z ${DOCKER_ZONE} clear docker
47 | else
48 | ssh ${NODE} svcadm -z ${DOCKER_ZONE} restart docker
49 | fi
50 | ssh ${NODE} svcadm -z ${DOCKER_ZONE} restart config-agent
51 |
--------------------------------------------------------------------------------