본문 바로가기

Linux Distributions

How to ubuntu with docker container

728x90
반응형

How to ubuntu with docker container

1. Pull the Ubuntu image from Docker Hub.

docker pull ubuntu

 

2. Create a new container based on the Ubuntu image.

docker run -it ubuntu

 

3. Access the Ubuntu container.

docker attach ubuntu

 

4. Perform your desired tasks within the Ubuntu container.

 

5. Stop the Ubuntu container.

docker stop ubuntu

 

6. Remove the Ubuntu container.

docker rm ubuntu

 

Run a Docker container based on the "anti1346/ubuntu2204:systemd" image, open an interactive session using a Bash shell inside the container, and automatically destroy the container after shutdown.

docker run -it --rm anti1346/ubuntu2204:systemd bash

Let's break down the command:

  • "docker run" starts a new Docker container.
  • "-it" attaches an interactive terminal to the container.
  • "--rm" specifies that the container should be automatically removed after it exits.
  • "anti1346/ubuntu2204:systemd" is the name of the Docker image used for the container. In this case, it is an Ubuntu 22.04 image with systemd.
  • "bash" specifies the command to run inside the container. In this case, it launches the Bash shell.

 

728x90
반응형