Docker Community Forums

Share and learn in the Docker community.

Dockerfile: FROM ... as


(Tech687) #1

$ cat Dockerfile
FROM debian as abc

$ docker build .
Sending build context to Docker daemon 2.048 kB
Step 1/1 : FROM debian as abc
Error parsing reference: “debian as abc” is not a valid repository/tag: invalid reference format

Because it does not work?


(Todd W.) #2

The ‘as’ should be capitalized.

FROM

FROM [AS ]

Or

FROM [:] [AS ]

Or

FROM [@] [AS ]


(Tech687) #3

Error parsing reference: “debian AS abc” is not a valid repository/tag: invalid reference format


(Rubendario) #4

I ran your Dockerfile on my linux and work just fine.

ruben@arch> sudo docker build .  
[sudo] password for ruben: 
Sending build context to Docker daemon  2.048kB
Step 1/1 : FROM debian as abc
latest: Pulling from library/debian
3e731ddb7fc9: Pull complete 
Digest: sha256:4fcd8c0b6f5e3bd44a3e63be259fd0c038476d432953d449ef34aedf16def331
Status: Downloaded newer image for debian:latest
---> 1b3ec9d977fb
Successfully built 1b3ec9d977fb

ruben@arch> sudo docker inspect 1b3ec9d977fb
[
{
    "Id": "sha256:1b3ec9d977fb413627aca6244b27538013905167db25702a500474616ac2e3c8",
    "RepoTags": [
        "debian:latest"
    ],
    "RepoDigests": [
        "debian@sha256:4fcd8c0b6f5e3bd44a3e63be259fd0c038476d432953d449ef34aedf16def331"
    ],
    "Parent": "",
    "Comment": "",
    "Created": "2018-02-15T02:01:04.479066259Z",
    "Container": "480024cbe949b04c28ba311b9c6c470f0fb2f859c1c0aa4688f82d136cd7c904",
    "ContainerConfig": {
        "Hostname": "480024cbe949",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": [
            "/bin/sh",
            "-c",
            "#(nop) ",
            "CMD [\"bash\"]"
        ],
        "ArgsEscaped": true,
        "Image": "sha256:c3bad1f7897bee48854593d040d7c9717b6a706e7e357323425d6d4b84a1dae8",
        "Volumes": null,
        "WorkingDir": "",
        "Entrypoint": null,
        "OnBuild": null,
        "Labels": {}
    },
    "DockerVersion": "17.06.2-ce",
    "Author": "",
    "Config": {
        "Hostname": "",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": [
            "bash"
        ],
        "ArgsEscaped": true,
        "Image": "sha256:c3bad1f7897bee48854593d040d7c9717b6a706e7e357323425d6d4b84a1dae8",
        "Volumes": null,
        "WorkingDir": "",
        "Entrypoint": null,
        "OnBuild": null,
        "Labels": null
    },
    "Architecture": "amd64",
    "Os": "linux",
    "Size": 100124083,
    "VirtualSize": 100124083,
    "GraphDriver": {
        "Data": {
            "MergedDir": "/var/lib/docker/overlay2/823654776d0576c2659611546fa7c62ed086f86acb888a94e27c47b15691b33e/merged",
            "UpperDir": "/var/lib/docker/overlay2/823654776d0576c2659611546fa7c62ed086f86acb888a94e27c47b15691b33e/diff",
            "WorkDir": "/var/lib/docker/overlay2/823654776d0576c2659611546fa7c62ed086f86acb888a94e27c47b15691b33e/work"
        },
        "Name": "overlay2"
    },
    "RootFS": {
        "Type": "layers",
        "Layers": [
            "sha256:8568818b1f7f534832b393c531edfcb4a30e7eb40b573e68fdea90358987231f"
        ]
    },
    "Metadata": {
        "LastTagTime": "0001-01-01T00:00:00Z"
    }
}
]

(Tech687) #5

I reinstalled the latest version of docker and now it seems functional :slight_smile: