ashudevcodes / docker-container-replica

Docker Container Replica from Scratch and Its Working in GoLang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

	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

    sudo go run main.go run /bin/bash

About

Docker Container Replica from Scratch and Its Working in GoLang


Languages

Language:Go 100.0%