Jas
Jas

Reputation: 15093

docker run ubuntu on mac and nothing happens

i'm on mac running:

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

my-mac:mydir$ docker run ubuntu /bin/bash
my-mac:mydir$

am i doing something wrong? shouldn't I get into the ubuntu shell?

Upvotes: 9

Views: 9217

Answers (2)

VonC
VonC

Reputation: 1323403

By running docker run ubuntu /bin/bash, docker create a randomly-named container from the image ubuntu and runs a bash without stdin, stdout nor stderr then bash exits (right after being started).

Try at least to set a tty and interactive mode (aka foreground mode):

 docker ps -a
 # if not exited, stop it first
 docker stop <container_id>
 # remove the container which cannot be used
 docker rm <container_id>

 # let's try again
 docker run -it --rm --name=test ubuntu bash

As commented by physincubus:

  • '-it' is the bit that makes it interactive,
  • '--rm' removes the container when you exit (so if you want to be able to exit for detach and reattach later, do not do this), and
  • '--name' allows you to name the container more explicitly in case you want to run multiple instances of the same container

Upvotes: 18

Chetan kapoor
Chetan kapoor

Reputation: 855

Run it with following command

docker run -it ubuntu /bin/bash

Then you will get bash prompt of ubuntu container

Upvotes: 1

Related Questions