Docker container run -it centos /bin/bash. As you can see from the output once the container is started the command prompt is changed which means that you’re now working from inside the container: [email protected] /# To list running containers:, type: docker container ls. Install Docker Compose on CentOS 8 CentOS 8. We have Docker installed and running, let’s now change gear to Docker Compose. Docker Compose is a tool used to define and run multi-container Docker applications. The application services are configured using a Compose file. The official build of CentOS.

I’m just getting started with Docker. I’ve thought for years that containerization is a great idea, but I haven’t actually done anything with containers yet. Time to get started.

Bash

I ran through a couple tutorials on the Docker docs site and created a cloud.docker.com account to get some basic familiarity.

I found the CentOS container repository on Docker Hub: https://hub.docker.com/_/centos/

Let’s try running it!

$ docker pull centos
$ docker run centos

Docker Run Centos Image Bash

Did it do anything? It looks like it did something. At least, it didn’t give me an error. What did it do? How do I access it?

Mac

$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Docker run centos bash commandCentos

Nothing is actively running. That makes sense, because we’re not telling the containerized OS to do anything — it starts, it doesn’t have anything to do, and so it shuts down immediately. Instead we can tell it to run interactively and with a terminal by specifying a couple options:

-i, --interactive
-t, --tty
(“allocate a pseudo-TTY”, i.e. a terminal)
(see docker run --help for details)

$ docker run -i -t centos
[[email protected] /]#

I’m in!

What if I want to modify the container? Right now it is pretty bare-bones. For example, this doesn’t even have man installed:

[[email protected] /]# man man
bash: man: command not found

[[email protected] /]# yum install man
..
[[email protected] /]# man man
No manual entry for man

Quite the improvement! Now we need to save our change:

[[email protected] /]# exit

$ docker commit 4f0b435cdbd7 man-centos
$ docker run -i -t man-centos

[[email protected] /]# man man
No manual entry for man

Docker Run Centos Bash Ubuntu

Progress! Now we have a CentOS container where man is already installed. Exciting.

Sudo Docker Run –it Centos /bin/bash

I can’t (that I know of) inspect the container and know whether or not man is installed without running it. That’s fine for many cases, but next I will attempt to figure out how specify via a Dockerfile that man is installed.

Coments are closed
Scroll to top