Not able to see file after creating it using docker command and committing the changes

I created docker container with name “task1”.

I execute a shell command which creates a file foo.txt containing the word “hello”.

  • How to use Java Buildpack in Bluemix Docker?
  • How to get remote access to a private docker-registry?
  • Allocate or Limit resource for pods in Kubernetes?
  • Dynamically routing hosts to dockers
  • Dockerizing an existing Project
  • How can I provision a Docker image using Ansible without installing locally?
  • I commit the docker container “task1”

    I enter into the docker container “task1” in interactive mode with -it command

    But I do not see the file “foo.txt” . I am expecting it because I have committed the container.
    However, when I just pass “ls” command and execute it in the same container “task1”, it shows the file “foo.txt”.

    What is the problem here? The below is the console detail where I am trying the above activities. Appreciate your help. Thanks.

     ~/G/S/d/d/H/test_io   master ±  docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    35784a56ffa3        task1               "/bin/bash"              5 seconds ago       Up 4 seconds                                 task2
    eb03c7b89e36        task1               "/bin/bash"              6 minutes ago       Up 6 minutes                                 clever_bell
    352c6f8f1ff2        registry:2          "/bin/registry /etc/d"   10 days ago         Up About an hour    0.0.0.0:5000->5000/tcp   registry
    
    ~/G/S/d/d/H/test_io   master ±  docker exec -it eb03c7b89e36 script /dev/null -c "echo 'Hello' > foo.txt"
        Script started, file is /dev/null
        Script done, file is /dev/null
    
    
    
    
      ~/G/S/d/d/H/test_io   master ±  docker ps
        CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
        35784a56ffa3        task1               "/bin/bash"              2 minutes ago       Up 2 minutes                                 task2
        eb03c7b89e36        task1               "/bin/bash"              8 minutes ago       Up 8 minutes                                 clever_bell
        352c6f8f1ff2        registry:2          "/bin/registry /etc/d"   10 days ago         Up About an hour    0.0.0.0:5000->5000/tcp   registry
    
    
    
       ~/G/S/d/d/H/test_io   master ±  docker commit eb03c7b89e36
        6d8666dc72caa36f436c46fe65e5beb6a1421ea27867153658303e430a33f126
    
    
    
       ~/G/S/d/d/H/test_io   master ±  docker run -it task1
        root@aad8db09c5fe:/# ls
        bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
        root@aad8db09c5fe:/# exit
        exit
    
    
    
      ~/G/S/d/d/H/test_io   master ±  docker exec -it eb03c7b89e36 ls
        bin   dev  foo.txt  lib    media  opt   root  sbin  sys  usr
        boot  etc  home     lib64  mnt    proc  run   srv   tmp  var
    
     ~/G/S/d/d/H/test_io   master ±  docker start clever_bell
        clever_bell
    
     ~/G/S/d/d/H/test_io   master ±  docker run -it task1
        root@4bfba10c7c49:/# ls
        bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
        root@4bfba10c7c49:/# exit
        exit
    

  • Access a service from one container to other
  • How to communicate between Docker containers via “hostname”
  • Seeding data in a Mongo db within a linked Docker container
  • Docker add files to VOLUME
  • Docker build: is the content from a layer keep on the next one?
  • Docker remove <none> TAG images
  • One Solution collect form web for “Not able to see file after creating it using docker command and committing the changes”

    docker commit <container> does not alter the container’s image in any way; it simply creates a new image separate from the original image. If you want the test1 image to be updated, you need to specify a name for the new image: docker commit <container> test1.

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