#!/bin/bash

#set -x

cd $(dirname $0)

SHAREDDIR=$PWD/shared
CONTAINER=build-aosp
REPOSITORY=gmacario/build-aosp

# Create a shared folder which will be used as working directory.
mkdir -p $SHAREDDIR

# Try to start an existing/stopped container with the given name $CONTAINER.
# Otherwise, run a new one.
if docker inspect $CONTAINER >/dev/null 2>&1; then
    echo -e "\nINFO: Reattaching to running container\n"
    docker start -i $CONTAINER
else
    echo -e "\nINFO: Creating a new container\n"
    docker run -v $SHAREDDIR:/home/build/shared -i -t \
        --name $CONTAINER $REPOSITORY
fi

exit $?

#!/bin/bash

#set -x

cd $(dirname $0)

TMPDIR=$PWD/tmp
CONTAINER=build-aosp
REPOSITORY=gmacario/build-aosp

# Create a shared folder which will be used as working directory.
mkdir -p $TMPDIR

# Try to start an existing/stopped container with the given name $CONTAINER.
# Otherwise, run a new one.
docker start -i $CONTAINER || \
	docker run -v $TMPDIR:/home/build/tmp -i -t \
	--name $CONTAINER $REPOSITORY
# /bin/sh -c "screen -s /bin/bash"

exit $?

--- 
+++ 
@@ -4,22 +4,18 @@
 
 cd $(dirname $0)
 
-SHAREDDIR=$PWD/shared
+TMPDIR=$PWD/tmp
 CONTAINER=build-aosp
 REPOSITORY=gmacario/build-aosp
 
 # Create a shared folder which will be used as working directory.
-mkdir -p $SHAREDDIR
+mkdir -p $TMPDIR
 
 # Try to start an existing/stopped container with the given name $CONTAINER.
 # Otherwise, run a new one.
-if docker inspect $CONTAINER >/dev/null 2>&1; then
-    echo -e "\nINFO: Reattaching to running container\n"
-    docker start -i $CONTAINER
-else
-    echo -e "\nINFO: Creating a new container\n"
-    docker run -v $SHAREDDIR:/home/build/shared -i -t \
-        --name $CONTAINER $REPOSITORY
-fi
+docker start -i $CONTAINER || \
+	docker run -v $TMPDIR:/home/build/tmp -i -t \
+	--name $CONTAINER $REPOSITORY
+# /bin/sh -c "screen -s /bin/bash"
 
 exit $?
Replace TMPDIR with SHAREDDIR (/home/build/shared)

Signed-off-by: Gianpaolo Macario <d50c09b51e61901a1c5054dce86f92776c198faa@mentor.com>
