Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a user to issue commands with sudo, fixes #918, fixes #919, fixes #920 #935

Merged
merged 7 commits into from Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/ddev/cmd/exec_test.go
Expand Up @@ -36,6 +36,11 @@ func TestDevExec(t *testing.T) {
assert.NoError(err)
assert.Contains(string(out), "/")

args = []string{"exec", "sudo", "whoami"}
out, err = exec.RunCommand(DdevBin, args)
assert.NoError(err)
assert.Contains(string(out), "root")

cleanup()
}
}
1 change: 1 addition & 0 deletions containers/nginx-php-fpm-local/files/etc/sudoers.d/ddev
@@ -0,0 +1 @@
ALL ALL=NOPASSWD: ALL
2 changes: 2 additions & 0 deletions docs/users/cli-usage.md
Expand Up @@ -384,6 +384,8 @@ The `ddev exec` command allows you to run shell commands in the container for a

To run a shell command in the container for a different service, use the `--service` flag at the beginning of your exec command to specify the service the command should be run against. For example, to run the mysql client in the database, container, you would run `ddev exec --service db mysql`.

To run privileged commands, sudo can be passed into `ddev exec`: `ddev exec sudo <command>`.

Commands can also be executed using the shorter `ddev . <cmd>` alias.

### SSH Into Containers
Expand Down
1 change: 1 addition & 0 deletions docs/users/extending-commands.md
Expand Up @@ -41,6 +41,7 @@ hooks:
post-import-db:
- exec: "drush cc all"
- exec: "drush uli"
- exec: "sudo mkdir /hello"
Copy link
Member

@rfay rfay Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a post-start with

- exec: sudo apt-get update
- exec: sudo apt-get install -y ghostscript sqlite3 php7.2-sqlite3

```

Example:
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Expand Up @@ -20,7 +20,7 @@ var DockerComposeVersionConstraint = ">= 1.10.0-alpha1"
var WebImg = "drud/nginx-php-fpm-local"

// WebTag defines the default web image tag for drud dev
var WebTag = "v0.19.0" // Note that this can be overridden by make
var WebTag = "2018-06-20_exec-sudo" // Note that this can be overridden by make

// DBImg defines the default db image used for applications.
var DBImg = "drud/mariadb-local"
Expand Down