mkdir command with docker

Inside my docker container, this command mkdir -p -m 755 directoryName creates a directory (Blue File) at the given path. However, outside docker, when I attempt to create a directory with the same command mkdir -p -m 755 ContainerID:/root/.../directoryName it seems to be creating an Executable (Green File).

This is causing trouble because with my “create directory” command i’m copying stuff to it, and the command is failing when I do it outside of docker.

  • Starting multiple services in docker entrypoint
  • Redis server fails to start in docker
  • Install R on windows nanoserver image using powershell
  • Adding services in different consul clients running on same host
  • Pass a variable to a Dockerfile from a docker-compose.yml file
  • What is the difference between Docker Hub Registery and Quay.io?
  • This is what my full command will be, when I execute outside docker:

    mkdir -p -m 755 ContainerID:/root/../dirName && docker cp someImage.jpg ContainerID:/root/../dirName
    

    Any thoughts on how to to make this work?

  • Docker machine timeout - how to fix without destroying the machine?
  • Remove docker container at the end of each test
  • Why is it not possible to call locale-gen with sudo inside a docker container?
  • Running cron python jobs within docker
  • Initializing database in the base image of a running container
  • How to use a bash script in Alpine Linux?
  • One Solution collect form web for “mkdir command with docker”

    To be honest, I have never heard of such mkdir syntax, referencing a different host, but in any case (even if it was supported) I would not use it. You should execute anything you want to to inside a docker container as docker exec ContainerID mkdir -p -m 755 /root/../dirName

    If you want to put several commands inside the same docker exec call you can do it by executing docker exec ContainerID bash -c "whatever && whatever2 && ... whateverX"

    Have in mind that these commands will be executed as the user referenced in the Dockerfile with an USER clause, defaulting to root. There are some images in which the user is set to something different, leading to permission issues while doing stuff like this. The right approach to follow would depend on whatever you want to achieve.

    Hope that helps! 🙂

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.