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

Updated Docker Installation Alias for linux #1492

Merged
merged 8 commits into from
Feb 7, 2024

Conversation

Akash-Singh04
Copy link
Contributor

Related Issue

  • Only add sudo to docker alias for linux if required

Closes: #1469

Describe the changes you've made

  • We check if docker ps runs successfully without sudo.
  • If it does, the alias is created without sudo, otherwise, it's created with sudo, otherwise not

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

NIL

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

NIL

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@Akash-Singh04
Copy link
Contributor Author

@slayerjain Kindly look into this PR for the issue you opened

@slayerjain
Copy link
Member

@Akash-Singh04 thanks for the PR.

@PranshuSrivastava since you were working on this script, can you please and test this?

@PranshuSrivastava
Copy link
Member

Hey @Akash-Singh04, thanks for the PR. But this is not a good solution for the problem. This is kind of a hack to check if docker runs with sudo or not. So in macos sudo is generally not required, but in linux sudo is required but it can be removed with a specific configuration. So take a look at how the need for sudo is removed in Linux, and check if the user's system has that configuration or not, and if it does then don't use sudo

@Akash-Singh04
Copy link
Contributor Author

Akash-Singh04 commented Feb 6, 2024

Hey @Akash-Singh04, thanks for the PR. But this is not a good solution for the problem. This is kind of a hack to check if docker runs with sudo or not. So in macos sudo is generally not required, but in linux sudo is required but it can be removed with a specific configuration. So take a look at how the need for sudo is removed in Linux, and check if the user's system has that configuration or not, and if it does then don't use sudo

In this updated implementation, we check if the current user belongs to the docker group using the groups command since users inside the docker group have permission to run docker without the sudo command

Reference: https://askubuntu.com/a/477554

@PranshuSrivastava Kindly check this implementation and let me know if it is an optimal solution. If you have any other resources that are viable to this issue, kindly share.

Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

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

The rest of the changes look good, there is just one comment that you need to address.

keploy.sh Outdated
docker volume create --driver local --opt type=debugfs --opt device=debugfs debugfs
fi
alias keploy='docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v $(pwd):$(pwd) -w $(pwd) -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy'
else
Copy link
Member

Choose a reason for hiding this comment

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

use else if here, we are doing this specifically on linux

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kindly check if this was the intended change

Akash-Singh04 and others added 2 commits February 7, 2024 16:42
Signed-off-by: Akash <akashsingh2210670@gmail.com>
Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

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

LGTM

@PranshuSrivastava PranshuSrivastava merged commit aaa178f into keploy:main Feb 7, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2024
@Akash-Singh04 Akash-Singh04 deleted the dockeraliasupdate branch February 7, 2024 16:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: only add sudo to docker alias for linux if required
3 participants