Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
```