Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker run ubuntu on mac and nothing happens

Tags:

docker

macos

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?

like image 376
Jas Avatar asked Mar 02 '16 07:03

Jas


2 Answers

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
like image 193
VonC Avatar answered Nov 12 '22 03:11

VonC


Run it with following command

docker run -it ubuntu /bin/bash

Then you will get bash prompt of ubuntu container

like image 1
Chetan kapoor Avatar answered Nov 12 '22 05:11

Chetan kapoor