Forivin
Forivin

Reputation: 15528

Docker: Why does my home directory disappear after the build?

I have a simple docker file:

FROM ubuntu:16.04

MAINTAINER T-vK

RUN useradd -m -s /bin/bash -g dialout esp

USER esp 

WORKDIR /home/esp

COPY ./entrypoint_script.sh ./entrypoint_script.sh

ENTRYPOINT ["/home/esp/entrypoint_script.sh"]

when I run docker build . followed by docker run -t -i ubuntu and look for the directory /home/esp it is not there! The whole directory including it's files seem to be gone.
Though, when I add RUN mkdir /home/esp to my docker file, it won't build telling me mkdir: cannot create directory '/home/esp': File exists.

So what am I misunderstanding here?

I tested this on Debian 8 x64 and Ubuntu 16.04 x64. With Docker version 1.12.2

Upvotes: 0

Views: 1783

Answers (1)

Boynux
Boynux

Reputation: 6222

Simply change you Docker build command to:

docker build -t my-docker:dev .

And then to execute:

docker run -it my-docker:dev

Then you'll get what you want. you didn't tag docker build so you're actually running Ubuntu image.

Upvotes: 1

Related Questions