Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashudevcodes/docker-container-replica
Docker Container Replica from Scratch and Its Working in GoLang
https://github.com/ashudevcodes/docker-container-replica
containers docker golang namespace
Last synced: about 2 months ago
JSON representation
Docker Container Replica from Scratch and Its Working in GoLang
- Host: GitHub
- URL: https://github.com/ashudevcodes/docker-container-replica
- Owner: ashudevcodes
- Created: 2024-05-20T06:27:40.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T04:43:52.000Z (8 months ago)
- Last Synced: 2024-05-22T08:05:03.901Z (8 months ago)
- Topics: containers, docker, golang, namespace
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Container From Scratch
This Go code helps create a container similar to Docker using the `os` module and namespaces. This code will change the hostname of the user but in a separate user space. It will not affect the main root of the Linux kernel and will run any command you execute on your PC in a separate space.
## The Difficulties I Face
- **Sudo Error**: The program will not run as a non-root user; it requires root privileges.
- **User Application or Root User Application**: User applications do not run when executed in root mode because user and root applications are stored in separate bin folders.### Error I Face
```go
cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWNS,
}
```
- This code will not run without using `sudo` or being the root user.
- Ensure that Go is installed for the root user.## Command to Run This Code
```bash
sudo go run main.go run /bin/bash
```