Difference between revisions of "Rootless DOCKER"

From Pulsed Media Wiki
(Created page with " == Rootless Docker (Basic) == You can manage Docker containers without needing '''sudo''' '''systemctl --user''': This command manages systemd user services. Rootless Docke...")
 
(Guides: Linux: Information)
 
Line 6: Line 6:
 
'''systemctl --user''': This command manages systemd user services. Rootless Docker often uses systemd for managing its services within your user session.
 
'''systemctl --user''': This command manages systemd user services. Rootless Docker often uses systemd for managing its services within your user session.
  
 +
== How to rootless DOCKER in [[Pulsed Media]] servers ==
 +
 +
'''Set up user environment.'''
 +
 +
'''Set the XDG_RUNTIME_DIR environment variable'''
 +
(you can find it with 'id -u')
 +
 +
*export XDG_RUNTIME_DIR="/run/user/$(id -u)"*
 +
 +
'''Verify XDG_RUNTIME_DIR is set'''
 +
 +
*echo $XDG_RUNTIME_DIR*
 +
 +
'''Start the Docker user services'''
 +
 +
*systemctl --user start docker.socket*
 +
*systemctl --user start docker.service*
 +
 +
'''Enable the Docker user services to start on login'''
 +
 +
*systemctl --user enable docker.socket*
 +
*systemctl --user enable docker.service*
 +
 +
'''Add Docker binaries to your PATH (if not already done)'''
 +
 +
This assumes the rootless Docker binaries are in ~/.local/bin (/home/username/.local/bin
 +
 +
'''If you are using bash, then add to ~/.bashrc'''
 +
 +
*echo 'export PATH=/home/username/.local/bin:$PATH' >> ~/.bashrc*
 +
 +
'''you can log out and log back in (restart shell)'''
 +
 +
*source ~/.bashrc*
 +
 +
'''Verify Docker is running'''
 +
 +
*docker ps*
  
 
== Start: ==
 
== Start: ==

Latest revision as of 16:34, 24 June 2025

Rootless Docker (Basic)

You can manage Docker containers without needing sudo

systemctl --user: This command manages systemd user services. Rootless Docker often uses systemd for managing its services within your user session.

How to rootless DOCKER in Pulsed Media servers

Set up user environment.

Set the XDG_RUNTIME_DIR environment variable (you can find it with 'id -u')

  • export XDG_RUNTIME_DIR="/run/user/$(id -u)"*

Verify XDG_RUNTIME_DIR is set

  • echo $XDG_RUNTIME_DIR*

Start the Docker user services

  • systemctl --user start docker.socket*
  • systemctl --user start docker.service*

Enable the Docker user services to start on login

  • systemctl --user enable docker.socket*
  • systemctl --user enable docker.service*

Add Docker binaries to your PATH (if not already done)

This assumes the rootless Docker binaries are in ~/.local/bin (/home/username/.local/bin

If you are using bash, then add to ~/.bashrc

  • echo 'export PATH=/home/username/.local/bin:$PATH' >> ~/.bashrc*

you can log out and log back in (restart shell)

  • source ~/.bashrc*

Verify Docker is running

  • docker ps*

Start:

systemctl --user start docker.socket

systemctl --user start docker.service

Verify Docker is Running: docker info

docker ps --Lists currently running Docker containers.

docker ps -a --Lists all Docker containers (running and stopped).

docker images --Lists downloaded Docker images.

docker pull image_name --Downloads a Docker image from a registry (like Docker Hub).

docker run image_name --Creates and starts a Docker container from an image. You'll often need to specify ports and volumes.

docker run -d --name my_container -p 8080:80 nginx --Runs an Nginx container in the background (-d), names it my_container, and maps port 8080 on the host to port 80 in the container.

docker stop container_id_or_name --Stops a running Docker container.

docker start container_id_or_name --Starts a stopped Docker container.

docker restart container_id_or_name --Restarts a Docker container.

docker rm container_id_or_name --Removes a stopped Docker container.

docker rmi image_name --Removes a Docker image. Use with caution!


Set Environment Variables (If Necessary) echo $DOCKER_HOST

If it's not set or you encounter issues, you might need to set it manually. Consult the rootless Docker documentation or the output of your installation.