change PATH for building docker image

This command sudo docker build -t mydocker . build the image in /var/lib/docker. Is there a way to change it to another folder e.g. /home/user1/docker?

  • Docker build seems to not see requirements.txt even though it's in same directory
  • Xdebug on Docker doesn't work with PhpStorm
  • Dokku installation fails
  • Docker Image installing php modules
  • How to deploy code from localhost to docker containers using Git?
  • Attach terminal and launch docker compose?
  • Docker. Connect from one container to another container with mysql
  • Retain environment variable values for Symfony2 app development in Docker
  • How to install Ruby on docker?
  • connection refused when trying to connect redis using docker compose file
  • runing and sharing a host folder from a container using docker-py
  • Docker Container from php:5.6-apache as root
  • One Solution collect form web for “change PATH for building docker image”

    You have to restart the docker daemon with the -g option.

    docker -d -g /home/user1/docker
    

    or

    docker -d --graph="/home/user1/docker" 
    

    Keep in mind that once you do this, all your images for that docker daemon instance will get stored on /home/user1/docker

    And also that generally the Docker daemon runs a root. So it’s probably better to specify a directory owned by root

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