Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@happysundar
Last active February 1, 2017 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happysundar/f5c8e0e2a37d060b1daa25811561bdbe to your computer and use it in GitHub Desktop.
Save happysundar/f5c8e0e2a37d060b1daa25811561bdbe to your computer and use it in GitHub Desktop.
docker commands

Creating an image

  1. Create a single Dockerfile in ~/dockerfile/Dockerfile
FROM centos
VOLUME /Users/sundar.rajagopalan/Downloads
VOLUME /Users/sundar.rajagopalan/docker-dir
RUN ["useradd", "builder"]
RUN ["yum", "install", "rpm-build", "-y"]
RUN ["yum", "install", "redhat-rpm-config", "-y"]
RUN ["yum", "install", "wget", "-y"]
RUN ["install", "-d", "-o", "builder", "-m", "755", "/home/builder/rpmbuild"]
WORKDIR "/home/builder/rpmbuild"
RUN ["install", "-d", "-o", "builder", "-m", "755", "BUILD", "RPMS", "SOURCES", "SPECS", "SRPMS"]
ENTRYPOINT ["/bin/bash"]
  1. docker build -t rpmtest .

    This creates an image called “rpmtest”

  2. Verify that the image exists by doing a:

    docker images

  3. Launch an instance with:

    docker run -i -t -v /Users/sundar.rajagopalan/Downloads:/downloads /Users/sundar.rajagopalan/build:/build --name firstone rpmtest

  4. Start a stopped instance with:

    docker start -a -i <container_id>

Commands for regular user

  1. Connecting to an existing container docker attach <container_id or container_name>

  2. Removing an image docker rmi <image_name>

Remove old docker containers:

docker rm $(docker ps -q -f status=exited)

@lakshmantgld
Copy link

What does this line "RUN ["install", "-d", "-o", "builder", "-m", "755", "/home/builder/rpmbuild"]" specifically do ? install -d ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment